Beginners lesson on how to scale your Website?

So, what is Application Scalability?

When your website gets too much traffic(requests per minute or queries per second) which makes the website process the requests slowly and sometimes results in crashing of the server on which it is running.

To prevent failures and sluggishness add more resources on both hardware and software side that is scale your web application.

The common symptoms of web app that needs scalability are:

  1. Slow page loading
  2. Server getting crashed under high load(high RPM)
  3. Network Connections are timed out

Every web developer wants his app to have overall good user experience, to be fast, and be always online but scaling an app is not an easy task.

You should be aware of the right time your app needs scaling, you should know your app very well before starting to think about how and when to scale it.

Scaling an application is long time process which touches each and every module of your app and technology stack it uses including both hardware and software.

Be aware of What is the real problem?

Before scaling your app you need to be well aware of the problem your app is facing.

If an app is under too much load then one of the following server issues may be the real demon : running out of memory, CPU utilization, Disk I/O, networking I/O

To scale your app you need to figure out what are server issues you need to solve in able to make you app function and handle requests smoothly.

The apps real issue can be figured out by checking application’s metrics and through resource monitoring.

Some of the common resource monitoring tools for the servers are:

  1. AWS  and Azure Cloud Services offers great monitoring tools.
  2. in Heroku, New Relic provides best metrics
  3. For personally managed servers, solarwinds, Linode, Munin are good options.

The Approach which should be taken while monitoring a resource are:

  1. Check  monitoring reports and graphs.
  2. Check app logs to fine metrics like page and resource loading time etc.
  3. check if delays are caused due to DB servers or third-party APIs.

In most of the cases Database can actually cause real scaling issues. Caching DB Queries and Indexing DB can solve this.

Challenges you can face while scaling your app:

  1. Application can become complex to handle.
  2. Testing will be difficult.
  3. Local and production environment configuration will be difficult to match.

High level approach on how to scale your application

  • Try not to repeat the common operations
  • Cache and reuse data the user has already looked up
  • Avoid making requests from clients it already has instead redirect them.
  • Browser specific scaling

Solutions for scaling your app

Load Balancing

Your domain ( app.yourdomain.com) should point to a Load Balancer which should to route the requests between two or more web servers.

loadbalancer-blog.PNG

This setup will handle load better and the application will be less prone to failure.

You can add more servers behind the Load Balancer spreading request across the Machines

The Load Balancer will help you in handling temporary surge of high traffic.

Setting up a Load Balancer and web server is one time setup that doesn’t add much going complexity

Session Storage

A lot of applications handle sessions by storing a session ID in a cookie, and then storing the actual key/value data for each and every session in a database table.

If you find your database is getting slammed and your application does a lot of reading and writing to session data, it might be smart to rethink how and where you store your session data.

One option is to move your session storage to a faster, in-memory caching tool like redis or memcached.

Check more here Introduction to Session Storage

Choose the Right hosting

It’s not about only about your code it’s very important to have a proper server infrastructure and configuration.

This can solve by selecting proper tools and server providers.

See here Server Hosting

Caching DB queries

Simplest task to improve  speed of your web app will be caching the responses to frequent or slow queries in memory on the web server.

You obviously don’t need any machine to handle caching when you start a project.

See here Caching DB Queries in Java

Final Checklist to scale your application

  1. Sufficient physical resources like memory and CPU utilization
  2. Efficient DB engine and DB schema design.
  3. Memory management.
  4. Right server configuration.
  5. Beautiful modular coding with industry standards.
  6. Good resource monitoring tools.
  7. Less usage of external APIs is and database.
  8. Good design for handling background jobs.

Hope You guys have enjoyed the article!

Post your comments if you need any help or have any doubts on this.

Thanks! 🙂

 

 

 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s