WordPress has gone from a tool for creating blogs to a platform for web applications / framework / API Mobile. But these large volumes of content caused some problems in the performance of the site in some parts of the infrastructure, including the web servers.
When the application has millions of records in the database, without searching out the optimal use of indexes, the database can become overwhelmed. Furthermore, the large amount of (real or the result of DDoS-type attacks) access, common in large portals, cause impacts in processing the Web environment
Largely responsible for the sites so decide to increase vertically servers, ie putting the best servers with more processors and memory. But why not use a more distributed model and grow horizontally?
With the use of cloud computing structures, this is possible!
Hardware that allows the creation of many virtualized servers, coupled with technologies like, for example, VMware ESXi, Xen, and KVM If your option is to create a private cloud, will be necessary. You can also choose to use external services such as AWS Cloud Computing, Cloud Hosting Services and Google Cloud Platform for such purpose.
For horizontal growth of an application, the administrator must take into consideration some points, such as load balancing and high availability, horizontal growth of both environments (web and database), the centralization of static files in a centralized storage and deploy new versions of the application.
For a site that has millions of hits and user accounts, for example, the flattening of the database environment occurs from replication features provided by your DBMS. With this, several possibilities are open to developers, such as the charge distribution of the consultations held by the application among available servers, the separation of a master for insertion, modification and removal of records server operations, leaving the others just for answering queries selecting records, or separation servers for specific parts of the system (for example, a server responsible only to meet the search, the other to meet the sports section, and a third to meet the rest of the application).
In WordPress you can work with multiple database servers using the plugin HyperDB where these settings are performed through a simple text file format. This plugin is available for download here .
Realization of Dynamic Content Caching
Like any high-performance server, the gain is usually in the cache. Whether for static or dynamic content, caching is virtually rule for a cost-effective, either in the browser or on the server.
To assist in the performance of your WordPress application and, consequently, web servers, we use Varnish Cache for this function. It works as a reverse proxy, working in front of the web server and performing all requested content cache, either dynamic or static, and storing it in memory. When this content is requested again, Varnish serves content stored in its cache, thus saving processing backend.
Its use is of great value, especially when a site needs to handle high levels of traffic. In, when properly configured, production environments one Varnish server can serve more than 1,500 simultaneous requests and 150 Mbit / s of traffic with ease.
To increase the use of Varnish cache, it is important to use the plugin WP-Varnish, which, together with a hook, causes the cache of every application (except for administration) is maintained by time indeterminate. When the update is performed in a certain part of the application, this hook is fired, and Varnish will know that the cache should be invalidated.
Here is the WP-Varnish plugin available for download.
Balance the load
Optionally, Varnish can be used as a load balancer in front of Dedicated Web servers, distributing the load between different Web servers that will be in the backend . However, this approach may be a bottleneck in the horizontal growth, depending on the amount of memory required to quickly provide the application content.
For this reason, many administrators choose to use Nginx with Varnish (preferably), Apache or another web server in the same environment. Other solutions to control load balancing that require less computational power and memory of the environment are used in this scenario.
The simplest consist of using Apache web server (via mod_proxy_balancer) or Nginx for this function. In larger applications, more advanced solutions such as the use of advanced solutions or HAProxy clustering is required.
Replication of the application and monitoring of Web environments
In environments with multiple Web servers, you must ensure that all nodes contain the same version of the application. When adding content checks, either through scripts with file validation version, use code versioning or deployment automation tools like Chef or Puppet systems, you will ensure that the application to be distributed to its visitors is the same, regardless of the server to which the request is directed.
The validation is done also required for the removal of the load balancer of a Web server hosted with data center service provider when it contains a corrupted version of the application or unavailability of access to it. This validation depends on the adopted solution for the balancer.
Centralization of static content
In horizontally scalable applications, it is of utmost importance that static files are in a centralized location, whether in storage within its structure either an external service CDN ( Content Distribution Network ), accessible to all nodes in the Web environment.
These plug-ins can be obtained from the following addresses, respectively:
Remember: only one of these plugins must be installed!
Remember that, there is no "cookie cutter" ready to scale WordPress environments quickly and horizontally. Each application has its own peculiarities, for example, use of sessions, and this must be taken into account in planning and implementing your horizontalization environment. However, the main points raised here are the first step to your WordPress application is climbing quickly to meet your needs.