September 8, 2016
Facebook launched in February, 2004. By the end of that year, it had about one million users. By June, 2016, the number of monthly users averaged 1.7 billion. And users expect their walls and profile pages to load quickly; they expect to be able to read and write seamlessly. Over times, Facebook has had to scale its website exponentially to handle the massive increases in traffic.
Your business may not be the next Facebook. Nevertheless, you do expect it to grow and for the numbers of users to grow. And you want to keep UX just as awesome as you scale as it was when you launched. To do this, you should plan for a scalable website from the very beginning, whether you are developing it yourself or outsourcing the task. Here are six tips for developing the architecture for scalable websites.
All websites provide two services – writing and reading. Thus, the user of a WordPress ecommerce website searches for an item (writes) and then that item is retrieved for the user (read). Both of these functions must operate quickly. As a business scales, there will be the need for more storage, and for the rapid retrieval of information/data as the number of queries at the same time increases. To plan for this growth, Service-Oriented Architecture (SOA) should be considered – that is, dividing or de-coupling the write and read functions. In this way the two functions will not be competing with one another as queries increase. It is also easier to add shards later when the functions are separated.
When you launch, this will probably not be too much of an issue. You will most likely begin with a managed host, and things will be fine. In selecting a host, however, you need to plan in advance for scalability, as demand increases. You may want to move from traditional shared hosting to a virtual private server and, ultimately, even to dedicated hosting. If you are using WordPress, for example, there are several WordPress hosting services that provide tiered packages which allow easy and virtually seamless migration. Select your host with scalability in mind.
This is not optional in development architecture. In lay terms, this is like having a backup generator when the power goes out. You do not want the loss of something stored on one server to be “fatal.” If something should fail, there must be another copy of that piece running at the same time, to automatically take over.
You have to plan for added capacity. And you can do this vertically or horizontally. Vertical scaling means that you simply add more resources to you existing single server – more hard drives or a larger single server, for example. Horizontal scaling means you add more nodes – another server, for example. If you choose horizontal scaling, this must be planned for in the initial architecture. Modifying it later is a horrible task.
There can be issues with partitioning, such as longer load time or a piece of data being updated as someone is trying to retrieve. It would be a good idea to research mitigating these risks to avoid these issues.
As you scale and increase the amount of data you house, there is always the threat of loss of speed as a user searches for a tiny bit of data or information, from your now very large database. I/O disk reading is pretty slow, so you will want to use much faster memory access. The strategic solutions lie in caches, proxies, indexes, and load balancing. Each of these methods has is pros and cons, and the developer will need to select one based upon your individual circumstances.
Managing the write function is pretty easy when a site and business are new. As a site scales, however, write function slows down. To plan for this in advance, developers should build in asynchrony, and this can be done through queues. Thus a user can write and receive acknowledgement of that query and then go on to do other things until the request has been fulfilled. Synchronous systems don’t allow for this ad the user must just wait. Another benefit of using queues is that re-try requests can be built in should a request initially fail. While the architecture for queues has been challenging in the past, there are now some easy open source methods.
Building a scalable website takes a lot of planning, time and the understanding that mistakes will be made. As much as can be done up front, however, will save headaches down the road. These 6 tips should help.
Did you like this article?
Get more delivered to your inbox just like it!