Day 21 - Scaling - Horizontal vs Vertical Scaling - কোনটা কখন করবেন?
আপনার build করা application-টি এতই viral হয়ে গেছে যে, এর user base lakh cross করে গেছে। এবং concurrent user লাখের কাছাকাছি। এই অবস্থায় আপনার যে server আছে, তা user-দের load নিতে পারছে না। Peak time-এ user-দের wait করতে হচ্ছে। Data inconsistency-র একটা issue দেখা দিচ্ছে। মাঝে মাঝে server crash করছে। মাঝে মাঝে database-এ data insert হচ্ছে না। অবস্থা একদম বেগতিক হয়ে গেছে। এখন এর সমাধান হচ্ছে…
Day 21 - Scaling - Horizontal vs Vertical Scaling - কোনটা কখন করবেন?
A once-viral application now suffers as user count crosses a million, causing server overload and data inconsistency issues. Resource scaling has become necessary.
Vertical scaling involves increasing a single machine's CPU, memory, and storage. However, this approach has reached its limits as the largest server is also finite, and single points of failure can cause downtime.
Horizontal scaling, on the other hand, introduces multiple machines to distribute user traffic. Theoretically, this allows for unlimited scaling and higher availability. A load balancer directs traffic to these machines, ensuring optimal performance. But stateful applications, particularly those relying on session-based authentication, can cause issues. A separate Redis database with TTL expiration can mitigate this problem.
Database scaling is another critical consideration. With multiple servers handling user traffic, database load remains the same. Scaling databases can be challenging, with options like vertical scaling, read replicas, sharding, or caching. The best strategy depends on the specific situation and budget constraints. Overall, a thoughtful, stateless architecture and appropriate scaling methods will ensure smooth operation and high availability.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.