Horizontal Scaling for E-Commerce Applications with Step by Step

--

In this article, we are going to learn how to scale E-Commerce Applications with Horizontally and Step by Step.

Scaling an e-commerce application with Horizontally can be a complex task. We will iterate the architecture design one by one as per requirements. But before designing E-Commerce application, We should ask ourselves: What we have in our design toolbox ?

I have just published a new course — Design Microservices Architecture with Patterns & Principles.

Architecture Design Flow

Before we design any architecture we will always start from Problem which is Business Problem that drive our design considerations.

Software Architecture: Way of Learning

After that, we have learned Architecture Design Patterns and Principles about Scalability that you can check articles below:

So now, according to our Architecture Design flow at above, We are at Design step. But before design our system We should ask ourselves:

  • What we have in our design toolbox ? What we have learned so far ?

So that means, every time when we design our architecture, We should always start with writing down FRs and NFRs. Also its good to write-down Constraints or Limitations of project, for example cost, time and so on.

Architecture Design Toolbox

Here you can see the Architecture Design Toolbox that we will use during the article when designing our E-Commerce application:

Functional Requirements — FRs

Basically we are going to design simple e-commerce application and we need to write down business cases that means write down Functional-requirements:

  • List products
  • Filter products as per brand and categories
  • Put products into the shopping cart
  • Apply coupon for discounts and see the total cost all for all of the items in shopping cart
  • Checkout the shopping cart and create an order
  • List my old orders and order items history

Non-Functional Requirements — N-FRs

After getting requirements, as a Software Architect, we should consider Non-Functional Requirements. Since this is the first iteration of our e-commerce application, we don’t aim to super scalability and handle millions of request. Instead we will start with small and basics that's why I have added to

  • Availability
  • High number of Concurrent User
  • Maintainability
  • Flexibility
  • Testable
  • Scalability
  • Reliability

As you can see that we have added Scalability and Reliability and updated High number of Concurrent User.

Architecture Styles

After understanding Functional and Non-Functional requirements, now we can see our Design toolbox which includes Architectures, Patterns, Principles and Best Practices that we have learned and will apply on our project. Lets see which architecture styles that we have learned of course we have using Monolithic Architecture, Layered Architecture and Clean Architecture in our design.

As you know that, Clean Architecture also still following Monolithic architecture in terms of server design perspective so we can say that Layered Architecture is a sub-architecture style of Monolithic architecture. Because we will still have big application server, we won’t decompose servers now, instead we will separate logical layers into our 1 big application server in order to organize our projects better.

This time we will focus on scalability of e-commerce application with Clean Architecture.

Patterns & Principles

Its good to add principles in our picture in order to remember them always. And If we expand our Patterns & Principles, we can see that

And also we have learned and added below principles for this chapter;

We are going to consider these principles when design our architecture. So for now we have learned only these items and load our design toolbox with these items. But with continue our course we will discover new architectures, patterns and principles.

In order to provide scalability on Monolithic architecture, we need to increase E-Commerce application server. And put the Load balancer on front of our application. Now we can refactor our design as per non-functional requirements. According to our design toolbox, now lets design the first version of our e-commerce application with using Horizontally Scaling.

Design: Scalability — Horizontal Scaling — E-Commerce App

Here you can see the final architecture design for our e-commerce application which is applying Scalability — Horizontal Scaling and Load Balancer.

Now our application getting more request from different channels like mobile app, web browser so on. That means we need to managed Increase of Concurrent User. For that purpose we have added horizontal scaling application servers And put the Load balancer on front of our application.
Load Balancer will accommodate the request and send request to our e commerce application servers with using consistent hashing algorithms. This will provide to load equally for the servers.

As you can see that we have design our e-commerce application as a Monolithic architecture and handle to scalability requirements. Now we can handle good amount of requests in our e-commerce application. See that we have only horizontal scale to our application server, because it is state-less, has no state. But when it comes to our relational database server, we can’t scale horizontally due to it has state.

Adapt the Architecture — Scalability — Load Balancer — E-Commerce

We will implement possible Technology choices. As you know that we have designed our architecture with applying Horizontal Scaling and Clean Architecture.

You can see image of “Way of Learning — The Design Flow” of our articles: According to Flow, now its time to Adapting Technology Chooses.

In this step we will Apply Software Tools, Application Frameworks and Databases for our current design. You can find the potential tools on image bellowed:

As you can see the image, we used NGINX for Load Balancer. Of course, You can change and adapt different technology stack for your project requirements. I am only giving an example of technologies that are mostly using in software industry. As you can see that we have design and adapt with technology stack for our e-commerce application.

Design Microservice Architecture — E-Commerce App

If we design e-commerce application with Microservice architecture, you can see the image below:

In microservices, we can scale API Gateway and it will accommodate request from client applications.

What’s Next ?

Step by Step Design Architectures w/ Course

I have just published a new course — Design Microservices Architecture with Patterns & Principles.

In this course, we’re going to learn how to Design Microservices Architecture with using Design Patterns, Principles and the Best Practices. We will start with designing Monolithic to Event-Driven Microservices step by step and together using the right architecture design patterns and techniques.

--

--

Mehmet Ozkaya
Design Microservices Architecture with Patterns & Principles

Software Architect | Udemy Instructor | AWS Community Builder | Cloud-Native and Serverless Event-driven Microservices https://github.com/mehmetozkaya