Wednesday, September 5, 2007

BestCrosswords.com architecture

This document describes the hardware and software architecture of BestCrosswords.com (more info about the site here). Hopefully, it will provide guidance to people wanting to undertake such a project, but are not sure where to start.

WEBSITE STATS

Here are some stats to help you assess the kind of scalability that can be achieved with the architecture on the specified hardware.

As of September 2007:

Monthly visits: 1.4 million
Monthly pageviews: 5.5 million
Members: 224,000
Peak simultaneous visitors: 4,500
Database tables: 30
Database size: 1.6 GB
Average page rendering time: 50 ms
Average load average: 0.33
Average CPU usage: 10%

ARCHITECTURAL OVERVIEW

The site runs on a single machine. An Apache server receives web connections. Its functions include: URL rewriting and sanitizing, SSL and logging. It then proxies connections to a Tomcat appserver. Tomcat is responsible for processing requests. MySQL is used to persist web sessions and business data.

,--------, ,--------, ,-------,
--->| Apache |--->| Tomcat |--->| MySQL |
`--------' `--------' `-------'

Another machine is used for failover and has the same architecture.

HARDWARE & SOFTWARE

Both main and failover servers have the same configuration:

Hardware: 2.8 GHz Pentium 4 HT with 1 GB of memory
OS: Debian sarge (3.1) using the 2.6 kernel
Web: Apache 2.0.54
Appserver: Tomcat 5.5.17 with a customized JDBC session store
Database: MySQL 4.1.11 using the InnoDB engine
Mail: Exim 4.5


SOFTWARE ARCHITECTURE

I use a multi-tier architecture:

,--------,
-->| web UI |
`--------'
|
V
,---------, ,--------, ,-------------,
| service |-->| domain |-->| persistence |
`---------' `--------' `-------------'
^
|
,-------------,
-->| web service |
`-------------'

The following technologies are used: Tapestry 4.0 (web UI), Axis 1.3 (web service), Spring 2.0 (web UI, web service, service), Hibernate 3.2 (persistence).

PERSISTENCE LAYER

Hibernate is used to map domain model entities to the database. Transaction support is provided by the InnoDB MySQL storage engine.

I also use Data Access Objects to move data in and out of the database. The bulk of the code the DAOs implement is query logic. Separating that logic from the service layer is essential to make database optimization as easy as possible.

DOMAIN LAYER

The site domain logic is implemented in this layer. The domain model contains about two dozens entities, implemented as POJOs.

SERVICE LAYER

There are about a dozen services in this layer, all implemented using Spring beans. Spring provides transaction demarcation and caching. The services use the DAOs provided by the persistence layer to access and persist the entities.

The service layer has two purposes. First, it is used to implement workflow logic. Workflow logic is business logic that doesn't pertain to the domain model per say, for example, sending a welcome email when a new member signs up. Second, it provides a procedural and remotable API to the layers above.

Data Transfer Objects are used to carry data in and out of this layer. The choice to use DTOs was made at the beginning because it was my original intent to expose that layer through web services. However, I realized that I wouldn't be able to keep the services APIs stable enough for the needs of a public interface so I created a separate web service layer. Given the chance to redo it, I would probably ditch the DTOs and use the domain model entites for data transfers. This would save me a lot of data mapping code and would certainly improve performance.

WEB UI LAYER

The web UI layer contains a couple hundreds Tapestry pages and components.

The components get their data from the service layer. Since that data can oftentimes afford to be a bit out of date, a caching strategy has been devised. I simply stick a caching proxy in front of Spring beans for which I want to cache the results. I then inject the cached bean into the components that can benefit from the caching. This reduces the load on the database and improves page rendering time.

I originally designed the web UI layer to be stateless until the visitor logged in, then it would become stateful. Tapestry makes it easy to do that and since the majority of the visitors would not log in, all was well. However, as web UI layer became more sophisticated, statelessness started to become a hindrance so the web UI is now running statefully from the moment a visitor enters the site. This increased the number of web sessions in the database, so I had to rewrite parts of the Tomcat JDBC session store to accomodate for the extra load.

WEB SERVICE LAYER

This layer gives third-parties a programmatic access to the functionality of the site. It is composed of a thin facade of services adapting and stablizing the APIs provided by the service layer. In order for me to evolve the interface without disrupting established clients, I incorporated a version number to the API. So far, all the changes made have been backward compatible but it reassures me that, if need be, incompatible changes can be made to the API, as long as the version is increased.

FAILOVER

The site was initially hosted on a shared server. Then it was moved to a virtual private server to finally make the transition to dedicated server. Recently, repeated hardware failures and downtimes prompted me to start using DNS failover to provide redundancy to the site.

Before rolling out the solution, I performed an experiment to assess the viability of DNS failover. You can read more about it here. Granted, this solution doesn't provide 100% availability since DNS changes take time to propagate (even with a low TTL), but it's good enough.

The setup is simple, I have two machines, each running its own copy of the site. During normal operations, the DNS A record of the domain name points to the main machine. When a failure occurs, the A record is reconfigured to point to the failover machine. The failover machine is kept in sync with the main server using rsync over SSH for the filesystem data and MySQL master/slave replication over a Virtual Private Network for the database. I host the DNS records at DNSMadeEasy because they offer basic server monitoring and automatic DNS failover. An added bonus of the MySQL master/slave replication is that it simplifies database backups. I simply stop the slave from replicating while I do a database dump. It has no performance impact on the master and the dumps have referential integrity.

33 comments:

Mona Rathore said...

Anywhere anytime available fabulous 3Star Hyderabad escorts Girls. Our Escorts Agency provide high class Hyderabad Escorts services.
More Services:-
Independent Hyderabad Escorts
Independent Escorts in Hyderabad
Hyderabad Escorts Agency

Taniya Roy said...

Chennai exotic new comer Night Angels Chennai Female Models escorts.

http://yourescorts.in/
Chennai Escorts
Escorts in Chennai
Independent Escorts in Chennai

Meghna greatest responsible worldwide Escort Model in Hyderabad

http://meghnaescorts.com/
Hyderabad Escorts
Escorts in Hyderabad
Independent Hyderabad Escorts

Taniya Roy said...

Chennai exotic new comer Night Angels Chennai Female Models escorts.

http://yourescorts.in/
Chennai Escorts
Escorts in Chennai
Independent Escorts in Chennai

Meghna greatest responsible worldwide Escort Model in Hyderabad

http://meghnaescorts.com/
Hyderabad Escorts
Escorts in Hyderabad
Independent Hyderabad Escorts

Anonymous said...


Blog is very interesting...the information provided by you is impressive. if looking for call girls in goa check details
Call Girls in Goa
Goa Call Girls
Escorts in Goa
Goa Escorts
Independent Call Girls in Goa
Russian Call Girls Goa
Russian Independent Girls Goa

lakshmi ganapathi said...

The very next time I read a blog, Hopefully it doesn't disappoint me as much as this one. I mean, I know it was my choice to read, nonetheless I genuinely believed you would probably have something interesting to say. All I hear is a bunch of whining about something that you could possibly fix if you weren't too busy searching for attention.
passport agents in hyderabad

Reeha SIngh said...

Goa Escorts are the heaven for any human kind which will amuse you by its Female Escorts In Goa. So if you are in goa and looking for escorts in goa then 08585025915

Yuvraj Jadeja said...

Oh my gosh !!! you feel you have got a right Call Girls when you are in Goa. Then Rethink it buddies @@@ you have come to best Goa Call Girls 08585025915.

Yuvraj Jadeja said...

http://www.akshara-haasan.in/
Goa Call Girls, Goa Escorts, Goa Female Escorts, Escorts In Goa, Goa Escort Services, Goa HIFI Escorts, Goa Celebrity Escorts

Unknown said...

Escorts In Hyerabad
Hi cool buddies planning to spend some time with a quality girl then Hyderabad Escorts is the destination for you.

Unknown said...

You could both take assist of the Escorts in Ahmedabad for an unmarried day or can have them via your facet for a weekend ride. An afternoon or two with them is like rejuvenating each your thoughts and soul. Now, depending on the quantity of days or hours, their prices are likely to differ lots. Ensure to get in touch with the experts as soon as possible, and they may help you to avail greater statistics approximately their promising solutions.
http://www.rakhibhatt.co.in
http://ashnabhatiya.com
http://www.ahmedabadfemaleEscorts.com
http://www.ahmedabadqueen.com
http://www.indupathak.co.in
http://www.ahmedabadescort.net.in

Escorts in Ahmedabad
Escorts in Ahmedabad
Escorts in Ahmedabad
Escorts in Ahmedabad
Escorts in Ahmedabad
Escorts in Ahmedabad

Ahmedabad Escorts
Ahmedabad Escorts
Ahmedabad Escorts
Ahmedabad Escorts
Ahmedabad Escorts
Ahmedabad Escorts

Ahmedabad Escorts Agency
Ahmedabad Escorts Agency
Ahmedabad Escorts Agency
Ahmedabad Escorts Agency
Ahmedabad Escorts Agency
Ahmedabad Escorts Agency

independent Ahmedabad Escorts
independent Ahmedabad Escorts
independent Ahmedabad Escorts
independent Ahmedabad Escorts
independent Ahmedabad Escorts
independent Ahmedabad Escorts

ksarah said...

hi dude planning to visit Hyderabad and make some awesome moments in Hyderabad then get back to us at Hyderabad Escorts

Lovely Verma said...

Kolkata escort is a place where you can justify your requirements.
Kolkata Escorts Agency
Kolkata Escorts Service
Independent Kolkata Escorts
Escorts In Kolkata
Independent Escorts in Kolkata
High profile Kolkata Escorts Service - Kolkata Escorts
High class Independent Kolkata Escorts - Escorts in Kolkata
Delight full Kolkata Escorts Agency - Kolkata EscortJA

Mahi Sehgal said...


Escorts Service in Hyderabad
Hyderabad Escorts Service
Hyderabad Escorts
Escorts in Hyderabad

Mahi Sehgal said...


Escorts in Hyderabad
Escorts in Hyderabad
Escorts in Hyderabad
Escorts in Hyderabad

lavanya menon said...

Hi I am Lavanya Menon sexy and busty escorts in Goa. I am a resident of Goa I work in Goa escorts services for my livelihood. I provide my customers full support from myself. I am most sought out escorts in Goa because of my erotic and unique sex positions in the bed.

Goa escorts

Escorts in Goa

Goa escorts services

Independent Goa escorts.

DesiGirlsPhone said...

Girls WhatsApp numbers for friendship. get real girls WhatsApp mobile numbers for chat. make new friends online on WhatsApp dating site.

Call Girls
Mumbai call girls
Whatsapp Numbers
Aunty's Whatsapp numbers

Dream Divas said...

Hey, you have reached the fantastic place of VIP Delhi Call Girls service. We remain favorite for high profile call girls and High-Class Escorts. Our Apex class of escorts popular among the VIP person in Delhi. We have an exclusive range of the top class escorts to serve you better and best.
Delhi escort service

suhailmalik said...

thanks for sharing this we are from tour travel bazaar best north india travel agency we offer best jaipur tour packages delhi travel packages kashmir tour packages our tour company is based in leh and srinagar jammu and kashmir

Soniya Bajaj said...

I'm shakshi.I am working in India top most Escort servicecall girls in puri.If u want to join the all facility of escortscall girls in Cuttack.pls call me & whatssapcall girls in Bhubaneswar
visit the sites.call girls in Mumbai

Archana The best Call Girl said...

Hi friends ! I'm Archana Kumari. I like to have bed relationship with different persons rather than with a single man for the whole of life. I do it for enjoyment. If you are interested in me then,
Please follow me on the links given bellow.
Thanks.

Mumbai Escorts
Escorts in Jaipur
Call girls in Kolkata

Call girl in Mumbai
Model escorts in Mumbai
Escorts in Mumbai

MumbailCall gils
Kolkata Escorts agency
Kolkata Call girls

Robert Smith said...

Thanks once again for sharing your valuable thoughts.
cytolog.html

misoprostol.html

Eillen Sharma said...

Call Girls in Kolkata
Call Girls in Mumbai
Call Girls in Gurgaon

Call Girls in Kolkata
Call Girls in Mumbai
Call Girls in Gurgaon

Eillen Sharma said...

Call girls in Jaipur
Call girls in Jaipur
Call girls in Jaipur

Call girls in Jaipur
Call girls in Faridabad
Call girls in Bangalore

URVASHI said...

A warm welcome to the capital of India, Delhi. You can discover High Profile Escorts in Delhi. In the capital of India, Hot Delhi Escorts are thoroughly receptive who have all the information around one – one position which ordinarily customers take at bed when they are engaging in sexual relations with Model Escort in Delhi. Our prominent Escorts are absolutely delicious. They are additionally keeping up their figure and body size to fulfill with our customers when they book our Escort Service in Delhi.
Faridabad escort
Delhi escort

Akse Yaar said...

Pala Holidays offers Kashmir Tour Packages, The best Kashmir Tour Operators offers most exotic travel destinations in Kashmir Like Gulmarg, Pahalgam, Sonamarg and Srinagar, Kashmir tour packages are of different duration's and include tourism destinations like Srinagar, Gulmarg, Pahalgam and Sonmarag, Doodpathri in Kashmir and Katra and Patnitop if booked from Jammu, We at Pala Holidays Best Kashmir Tour Operators offer our clients best customized Kashmir Tour Plan Starting from Jammu, Katra, West Bengal

sweetneha said...

My name is Neha Gupta. I run my independent Mumbai Escorts Service. I am an independent Mumbai escort girl. My service charge is low according the market price. My service is super, because I know very well the personal need of my each customer. I am comfortable to provide my Mumbai Escorts Service at your home or in Hotel. 24X7 I am available. Visit- http://www.nehagupta.biz/ Call- +91 9OO4458359
Visit the Links Below and Have a Look At My Various Mumbai Escort Services-


Mumbai Escorts
escort-girl-in-mumbai

Escort Service In Mumbai
Mumbai Escort Service
Andheri Escorts Service
Mumbai Call Girls

Simran said...

My Name Is Priya Singh. I Run My Own Mumbai Escorts Service. I Am An Independent Mumbai Escort Girl. I Am Beautiful And Hot. My Service Charge Is Low And Service Is Super. Being Professional I Have Seven Years’ Experience As An Escort Girl. So I Understand And Feel The Real Needs And Requirement Of My Each Client. You Can Taste Me Any Time. According The Convenience You Can Avail My VIP Escort Service At Your Home Or In Hotel Also. To Book My VIP Mumbai Escort Service Call +91 9987215552. Visit http://www.escortagencyinmumbai.com/


Mumbai Call Girls
Mumbai Escorts In Vile Parle
Bandra Escorts
Juhu Escorts
Andheri Escorts
Escort Service In Colaba

sweetheart said...

My name is Arpita Jain. I run my independent Mumbai Escorts Service. I am an independent Mumbai escort girl. My service charge is low according the current market price. My service is super, because I know very well the personal requirement of my each customer. I am comfortable to provide my Mumbai Escorts Service at your home or in Hotel. Visit- http://www.arpitajain.org/ Call- +91 9OO4458359
Visit The Links Below And Have A Look At My Various Mumbai Escort Services-

Mumbai Escorts Service
Mumbai Escort Girls
Juhu Escorts

Escort Service In Mumbai


Aerocity Escorts said...

Aerocity Escorts is one of the extraordinary employments among such a significant number of Smart Girls and it is an incredible calling of luxury and flawlessness. You will get a tremendous pay just as incredible regard among others.

visit the website for more details -: Aerocity Escorts

Aerocity Escorts Service

Call Girl in Aerocity

Aerocity Escort Service

Aerocity Model Escorts

Aerocity Russian Escorts

Call Girl in Aerocity

Aerocity Escort

Call Girls in Aerocity

We have understudies have an incredible profile with an exclusive class, high-class Aerocity Russian escorts, top Aerocity model escorts etc.

Faridabad Escorts said...

Thanks for the post..I really loved it
call girls in jaipur
call girls in jaipur

escorts in jaipur
escorts in jaipur

escort service in jaipur
escort service in jaipur

Jaipur call girls
Jaipur call girls

Jaipur escorts
Jaipur escorts

Ritika Patel said...

Ahmedabad Escorts Services
Ahmedabad Call Girls Services
Vip escorts in Ahmedabad
Ahmedabad call Girls
Escorts in Ahmedabad
Sexy Call Girls in Ahmedabad
Escorts Ahmedabad
Ahmedabad Escorts
Call Escorts Ahmedabad
Call girls number ahmedabad
Call girls ahmedabad
Ahmedabad Girls
Ahmedabad Call Escorts

Ritika Patel said...

Surat Escorts
Surat Call Girls
Surat Escorts Service
Surat Call Escorts Service
Vip Escorts in Surat
Surat Escorts Girls
Escorts in Surat
Escorts Number Surat
Escorts Surat
Surat Call Escorts

Chitra Krishnan said...

call girls in bangalore

high profile tamil escort girls

kannada tv actress escorts

celebrity escort

escorts in dubai

dubai escort

dubai independent escorts