Saturday, January 18, 2014

Web site scalability

   It's many web site owner's dream to have millions of visitors.  Along with that comes the need to scale the sites to be able to handle that many visitors.  To that end, let's look at a simplified web site infrastructure diagram (thanks to a blog by Ryan).



     In this diagram there are two web servers and one database server.  Many of us may think scalability can be achieved simply by adding more instances of web servers and database servers. In the cloud where instance cost is so low (sometimes less than $0.01/hour),   the capacity can be scaled almost infinitely.   Unfortunately this is not true in many cases.

    While most of the time the web servers can be scaled by adding more instances,  database servers are much less so.   Some may not support multiple instances/shards.  Even when a database does support multiple instances/shards,  it typically doesn't scale linearly with the number of instances to infinity and the scalability diminishes quickly when the data scheme is more complex and degree of correlation among data is higher.

    Many client server interactions touch on the database, whether it's creating a new session, registering a user,  logging in or viewing a product.  In some sense, database is the most important part of the infrastructure (that's why Oracle made a lot of $$ :-)), but unfortunately it's also the part that's the hardest to scale.  Depending on the application,  some data structure may have such a high degree of correlation that it's virtually impossible to scale.

    From performance test's point of view, it's important to find the degree of scalability on a database.  If the database is scalable,  then it may be ok to run a test with less load and infer the capacity of a given system by means of extrapolation, otherwise, it's probably better to crank up the load to find the true capacity of the system - the point where the system can't catch up with demands/requests.
    One possible way to find the degree of database scalability is to compare the performance of one web server vs two web servers.  It's fairly easy to run test by pointing to two servers on NetGend platform:
 function userInit() {  
      var hosts = ["", ""];  
 function VUSER() {   
      host = randElement(hosts);  
      action(http, "http://${host}/");  
    If the response time dramatically improves with 2 servers over 1 server, the issue is on web server side. Otherwise, it probably indicates that the database doesn't scale as much you would like. You would need to emulate many virtual clients on the test platform to get the capacity of the system, a job where the NetGend platform excels, with 50,000 virtual client emulated on one system.

No comments:

Post a Comment