With growing software projects there may be a need to support a bigger number of users.    In such cases, ideally, you should include the possibility of high loading into the software architecture. However, several approaches can be applied for existing projects, too. Our experience in website development of high load projects is described below.

First step of optimization is clusterization of web nodes. A number of web nodes can be set in one cluster with one load balancer. That will increase the number of users that can use the website at the same time. This group of linked servers working together can give a better performance and availability than a single server provides.

Load balancing is linking multiple servers together to share the job execution workload, cache and request handling. Logically, from the user side, they are multiple machines, but functioning as a single virtual machine, so user cannot see if there is a cluster or not. Requests initiated by the user are managed and distributed among all the standalone computers to form a cluster. This results in balanced computational processing among different machines, which will improve the performance of the cluster system.

The most effective way to optimize each separate server is caching.

There are two types of cache for web instances:

    • caching server response. For this purpose we can use some kind of HTTP accelerator. For example, it can be Varnish with Nginx in the back end. When a request comes to the server, Varnish makes a lookup. If the page has already been opened by other users, this page is in cache and Varnish just returns it. Otherwise, Varnish sends a request to Nginx, receives the page, caches it and returns the response to user. Varnish must be configured for caching only static, not personal pages. (e.g. About, Home Page, etc.)
    • caching database server response. All website data are stored in a database. We can cache the results of some big (or even huge) database queries and store the results in Memcache. It helps to modify database loading and speeds up the website.

Another point of pages loading optimization is minification of stylesheets and JavaScript files. Minification is a process in which files are compressed by deletion of unnecessary spaces and by replacing long variable names by short ones.

All user session data and static files must be moved to separate servers.

A CDN can be used for files. CDN (Content Delivery Network) a distribution system of web servers on the Internet that accelerates the delivery of different files to users around the world. The CDN replicates the content files in several servers located in geographically dispersed datacenters. So, users in different regions can access the nearest data center and get a file at a high speed. Most CDNs are third-party services.

A MongoDB instance can be used for storing a user session. It is a NoSQL database that can be used for this purpose.

The easiest way to increase the capacity of a MySQL database is to upgrade the server hardware. Most often, this means adding a CPU and/or RAM, but can also include disk I/O capacity. It works only for dedicated servers.

A database can also be scaled in other ways. We propose such approaches:

The Master-Master replication. The Master-Master distributes query processing and data storage across multiple nodes to eliminate single points of failure and allow almost unlimited scaling.

The Master-Slave replication. Two or more database instances are used, one instance is the master and the others are slaves. All write requests (adding new data or modifying existing) are routed to the master instance, then copied to the slaves. Read operations are routed to the slave instances. In the event of a failure of the master, one of the slave instances must be designated as the new master and update operations rerouted.
DevOps consulting services can help you increase quality of software delivery on your project.