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:
- Slow page loading
- Server getting crashed under high load(high RPM)
- 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:
- AWS and Azure Cloud Services offers great monitoring tools.
- in Heroku, New Relic provides best metrics
- For personally managed servers, solarwinds, Linode, Munin are good options.
The Approach which should be taken while monitoring a resource are:
- Check monitoring reports and graphs.
- Check app logs to fine metrics like page and resource loading time etc.
- 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:
- Application can become complex to handle.
- Testing will be difficult.
- 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
Your domain ( app.yourdomain.com) should point to a Load Balancer which should to route the requests between two or more web servers.
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
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
- Sufficient physical resources like memory and CPU utilization
- Efficient DB engine and DB schema design.
- Memory management.
- Right server configuration.
- Beautiful modular coding with industry standards.
- Good resource monitoring tools.
- Less usage of external APIs is and database.
- 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.