EN
DevOps Updated

How to Ensure Cloud Scalability

Jane Vyshnova

Jane Vyshnova

CEO

Author

How to Ensure Cloud Scalability

Time to read: 11 minutes

Content

  1. What Is Scalability?
  2. Types of Scaling
  3. How to Ensure Maximum Scalability
  4. How Do We Handle Scaling Issues?
  5. Conclusion
Bookmark

To ensure cloud scalability, measure first, then scale in order: load-test to find how many requests per second your system handles and which component fails first, remove that bottleneck (often the database or missing caching), make the application stateless so it can run on several servers behind a load balancer, and only then automate scaling with clear minimum and maximum limits and health checks. A content delivery network (CDN) and shared caching take load off the servers before any of that is needed.

As load on computing systems grows, their architecture becomes more complex: new tools for performance optimisation are added, server capacity is expanded and services are split. All these processes come under one notion, scaling, and it is one of the core areas of DevOps work. For an online store, the test is usually a peak: a sale, a campaign or a seasonal rush. This article explains what scalability is, the types of scaling, the techniques that make a cloud system scale, and how Dinarys has approached scaling problems in client projects.

What Is Scalability?

Scalability is a system's ability to handle more load by adding resources, hardware or software, without redesigning the application. In practice, teams usually add servers or increase the capacity of existing ones, because rewriting code is the more drastic option. But adding resources only helps when the resource you add is the one that limits the system.

The need for scaling does not appear only when the system becomes slow in normal use. An architecture that performs well today can still fail when user traffic grows quickly or a campaign brings a sudden peak.

To see how much load your web server can handle, use a load-testing tool. ApacheBench (ab), for example, sends a set number of requests (the -n option) with a set number of them running at the same time (the -c option) and reports requests per second (RPS): the number of requests divided by the total time taken. ab tests one URL at a time and, as its documentation notes, does not fully implement HTTP/1.x, so use it for a first reading and use tools that replay realistic user journeys, such as browsing, search, cart and checkout, before an important peak.

Track response times as well as RPS. The point where RPS stops growing while response times keep rising shows the capacity of your current setup. Then check which component reached its limit first: application servers, database, cache, search or an external API.

For Kontakt Home, a semi-marketplace electronics and home appliances online store, the previous WordPress site could not handle a peak load of more than 7,500 requests per second. Dinarys built a new Magento 2 store integrated with the client's existing system, with a custom frontend in React and Magento as the API. The case page describes this starting problem and the new architecture; it does not publish load-test results for the new store.

Sometimes the cheaper answer is not scaling at all. Tuning server configuration, optimising slow database queries or adding caching may let you postpone scaling, and scaling a system before removing its main bottleneck only multiplies the cost.

The opposite also happens: sometimes the existing platform cannot be scaled at reasonable effort. For Prostor, an omnichannel drugstore chain, the case page lists performance patching and custom extensions on the existing platform among the options that were ruled out, because the constraints were architectural, including no path to Kubernetes-compatible infrastructure.

The table below links common symptoms to the first check and the usual fix.

Symptom under loadFirst checkLikely fixType of scaling
Response times rise, application servers' CPU is high, database is fineApplication profiling, PHP or runtime workers, server configurationOptimise code paths, then add application serversHorizontal
Database CPU or connections at their limit, application servers mostly idleSlow query log, missing indexes, repeated queriesOptimise queries, add caching, read replicas for read-heavy loadVertical for the database first, then read scaling
Same pages served again and again, such as category and product pagesCache hit rateFull-page or object cache shared by all serversNone until caching is in place
Slow images and static files for distant usersWhere users are, size of static assetsCDN for static assets and mediaNone for the origin servers
Users logged out or carts lost when a second server is addedWhere sessions and carts are storedMove sessions to a shared store; avoid local file storagePrerequisite for horizontal scaling
Peaks are short and predictable, such as campaignsTraffic history, campaign calendarAutoscaling with tested limits, plus scheduled capacity before known peaksAutomated horizontal
One external service, such as payment, ERP or search, times outIts rate limits and response timesQueues, timeouts, retries and caching of its responsesDecoupling rather than scaling

Worked example (illustrative figures). A load test of a store's category page reaches 120 requests per second. Raising the concurrency does not raise the RPS, but response times double. The database server is near its CPU limit while the application servers run at about 40%. Adding application servers would not help, because the database is the bottleneck. The team adds a full-page cache for category pages and fixes two slow queries; the same test now reaches a higher RPS and the application servers become the limit. At this point, horizontal scaling pays off. To size it, use a simple formula: number of servers = expected peak RPS × (1 + safety margin) ÷ RPS one server handles in your test. For example, an expected peak of 900 RPS with a 30% margin, and 150 RPS per server, gives 900 × 1.3 ÷ 150 = 7.8, so eight servers at the peak.

Why do we need to pay special attention to scalability?

A growing business needs to adapt quickly to changing demand. When your application is scalable, you can serve more customers during peaks without slowing down for everyone, run campaigns without fearing the traffic they bring, and grow into new markets. Scaling also affects cost: a system that can scale down after a peak avoids paying for idle capacity. Plan for scalability early in your growth strategy, because some decisions, such as where sessions and files are stored, are expensive to change later.

Types of Scaling

The most common types of scaling are vertical, horizontal and a combination of the two.

Vertical Scalability - scaling up

Vertical scaling increases the resources of an existing server: CPU, memory, storage or network capacity. The application and architecture stay the same, which makes it the quickest option. Its limit is the largest server available, and a single server remains a single point of failure.

Horizontal Scaling - scaling out

Horizontal scaling adds more identical nodes, such as servers, virtual machines or containers, and spreads the load between them. Kubernetes documentation describes the difference in the same way: horizontal scaling means deploying more Pods in response to increased load, while vertical scaling would mean assigning more resources, such as memory or CPU, to the Pods that are already running.

Sooner or later, vertical scaling reaches the technical limits of servers, and horizontal scaling takes over. It needs an application designed for it: no user sessions or uploaded files stored only on one server, and a load balancer in front of the nodes.

Diagonal Scaling

Diagonal scaling combines the two. You scale nodes up until they reach an efficient size, then add more nodes of that size. In the cloud, this often means choosing the right instance size first, then letting the number of instances change with demand.

The order of cloud scaling steps Seven steps for cloud scalability in order: 1, measure with a load test to find requests per second and the first bottleneck; 2, optimise the bottleneck with query fixes, caching and configuration; 3, scale up the limiting server if that is quicker; 4, make the application stateless, with sessions, carts and files in shared stores; 5, scale out with more nodes behind a load balancer; 6, automate with autoscaling within tested minimum and maximum limits; 7, offload images and static files to a CDN near users. A dashed line returns from step 7 to step 1: measure again after each change. Steps 1 and 2 are highlighted as often the cheapest capacity gain. Scale in this order and measure each step Skip steps your system does not need 1 Measure Load test: RPS and first bottleneck 2 Optimise the bottleneck Queries, caching, configuration 3 Scale up if quicker Bigger server for the limiting part 4 Make the app stateless Sessions, carts, files in shared stores 5 Scale out More nodes behind a load balancer 6 Automate Autoscaling within tested min/max 7 Offload to a CDN Images and static files near users Dashed line: measure again after each change Often the cheapest capacity gain
The order that keeps scaling cost-effective: measure, remove the bottleneck, then scale and automate. Repeat the load test after each change.

How to Ensure Maximum Scalability

Here are practical techniques for making a cloud system scale with the least expense.

Conduct load balancing

Load balancing distributes requests between several servers. The nginx documentation describes load balancing across multiple application instances as a commonly used technique for optimising resource utilisation, maximising throughput, reducing latency and ensuring fault-tolerant configurations.

Spreading the load also improves availability. If one node fails, the load balancer stops sending requests to it and the remaining nodes continue to serve users. Nginx, for example, supports round-robin, least-connected and IP-hash methods, and marks a server as failed for a while when its response fails with an error.

Sticky sessions, where a user is always sent to the same server, are a workaround, not a solution: when that server fails or is removed during scale-in, the user's session goes with it. Store sessions and carts in a shared store instead, so that any server can serve any request. In the cloud, managed load balancers from your provider usually take the place of self-managed ones.

Turn to auto web services scalability

Autoscaling changes computing capacity according to load. Cloud providers such as Amazon Web Services, Google Cloud Platform and Microsoft Azure offer it for virtual machines and containers.

In Amazon EC2 Auto Scaling, for example, you set a minimum and a maximum number of instances and, optionally, a desired capacity, and the service keeps the group within those limits. Scaling policies launch or terminate instances as demand rises or falls; health checks replace impaired instances; and new instances are registered with the load balancer automatically. AWS states that there are no additional fees for EC2 Auto Scaling itself: you pay for the resources it launches.

This is why autoscaling is cost-effective: you use as much capacity as you need at the moment, instead of buying and maintaining hardware for the peak. It also needs discipline. Set the maximum based on what your database and external services can handle, because more application servers will not help if the database is the limit. Test how quickly new instances become ready, and add capacity on a schedule before known peaks, such as a planned sale, rather than waiting for autoscaling to react.

Autoscaling always works together with load balancing.

Microservices containers, clusterization

Containers package a service with everything it needs to run, so that identical copies can start quickly on any node. Container orchestration groups the nodes into a cluster and adds or removes copies as load changes. In Kubernetes, a HorizontalPodAutoscaler adjusts the number of Pods to match observed metrics such as average CPU utilisation, average memory utilisation or a custom metric you specify.

Splitting an application into microservices lets you scale the busy parts, such as search or checkout, separately from the rest. It also adds operational complexity, so split where load or release independence justifies it, not by default.

Implement caching

When you scale horizontally, a cache in each server's local memory stops working well: each node has its own copy, and the copies diverge. Use a shared cache instead. Memcached, for example, describes itself as a distributed memory object caching system in which all servers look into the same virtual pool of memory; Redis is another common choice.

For an online store, a full-page cache for category, product and content pages takes most read traffic away from the application and database. Plan how the cache is updated when prices or stock change, so that customers do not see stale data.

Also prevent many requests from rebuilding the same expired cache entry at the same time, which can overload the database at exactly the wrong moment. Refresh important cache entries in the background, outside the user's request, or let only one request rebuild an entry while others receive the previous version.

With the right approach, caching often gives the largest capacity gain for the lowest cost.

Employ CDN services

A content delivery network (CDN) is a network of geographically distributed servers that cache content close to users. It is most useful for static files, such as images, scripts and stylesheets, and for audiences spread across several countries or regions. A CDN also takes load off your origin servers, because they no longer serve every image request.

CDN pricing usually depends on the volume of traffic delivered, so check your provider's current pricing against your traffic. If almost all your users are in one region close to your servers, the gain in speed is smaller, but offloading static traffic from the origin may still be worth it during peaks.

How Do We Handle Scaling Issues?

Scaling problems usually show up as a business problem first: a site that slows down or fails during a peak. The order described in this article applies here: measure the load the system must handle, find the component that fails first, and only then decide between optimisation, scaling the existing platform or, as in the Kontakt Home and Prostor examples above, a new architecture.

Scaling a platform also means scaling its operations. When every new customer needs its own environment, manual deployment becomes the bottleneck. For Backendless, a US mobile Backend-as-a-Service platform, Dinarys automated feature delivery and the deployment of customers' environments and optimised fault tolerance. The case page reports five times faster issue detection, six times faster incident reaction time and 40% faster environment deployment.

Conclusion

Scalability in the cloud comes from doing things in the right order: measure, remove the bottleneck, make the application stateless, then scale out and automate within tested limits, with caching and a CDN taking load off the servers. Done this way, your store can grow and handle peaks without paying for idle capacity the rest of the time.

If you want an outside view of your infrastructure before the next peak, contact us. Our DevOps support and maintenance and ecommerce performance optimisation teams can load-test your system, find the bottleneck and plan the scaling steps for your business. If you are building your own team, see our guide on how to hire a DevOps engineer.

Lassen Sie Profis Ihre Herausforderung meistern

Unsere zertifizierten Spezialisten finden die optimale Lösung für Ihr Unternehmen.

Bitte einen gültigen Namen eingeben
Bitte geben Sie ein gültiges Unternehmen ein
Bitte geben Sie eine gültige Telefonnummer an
Bitte geben Sie eine gültige E-Mail-Adresse ein
Kurze Botschaft

    Ihre Nachricht wurde erfolgreich verschickt. Wir melden uns in Kürze! Success icon