Search code examples
restarchitecturescale

Why do rest services scale?


What exactly does one mean when they say that rest services scale ?

Suppose I have a clustered environment with multiple instances of my application that exposes a rest service for some resources. Why does the rest service scale better than a traditional web service?

Thanks


Solution

  • REST, when applied correctly, scales well for many reasons:

    1. One of the major scalability problems in distributed system is storing application state on the server-side and guaranteeing consistency and availability across all nodes. Being stateless, you don't need to worry about that storage, and without a lot of communication between servers it's easier to scale horizontally. Nodes can be added and removed at will, and any node can respond any requests.

    2. With uniform interfaces, clients can deal with server-side changes more gracefully, and it's easier to deploy changes that help scalability. Many developers often have a lot of improvements ready to be deployed, but have to wait for clients to adapt to the changes won't break everything.

    3. Also, with hypermedia it's easier to direct a client transparently between different services, which makes it easier to separate concerns, to scale each part according to demand, and to use a server that's better suited for a particular type of resource.

    4. REST requires resources to explicitly declare their cacheability, and aggressive caching is not only encouraged but often necessary when you're using hypermedia. Good caching strategies may improve your scalability considerably.

    But it should be clear that REST rarely is the solution for scalability problems. REST is a solution for the problems involved in the long-term evolution of services. If this isn't your major concern, you can adopt some ideas to improve scalability without having to adhere to REST strictly.