为什么RESTful应用程序更容易扩展 [英] Why are RESTful Applications easier to scale

查看:151
本文介绍了为什么RESTful应用程序更容易扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是读到一个原因选择了一个REST风格的架构(其中包括)为web应用更好的可扩展性,高负荷。

I always read that one reason to chose a RESTful architecture is (among others) better scalability for Webapplications with a high load.

这是为什么?一个原因,我能想到的是,由于定义的资源这是为每个客户端一样,缓存变得更加容易。在第一次请求之后,后续请求是从memcached的实例,这也很好水平缩放服务。

Why is that? One reason I can think of is that because of the defined resources which are the same for every client, caching is made easier. After the first request, subsequent requests are served from a memcached instance which also scales well horizontally.

但不能还用传统的方法,即行为都设有codeD中的URL,例如,做到这一点(booking.php /用户id = 123&安培; travelid = 456安培; foobar的= 789)。

But couldn't you also accomplish this with a traditional approach where actions are encoded in the url, e.g. (booking.php/userid=123&travelid=456&foobar=789).

推荐答案

REST的一部分是确实的URL部分(它在REST的R)但S缩放更重要的是:国家

A part of REST is indeed the URL part (it's the R in REST) but the S is more important for scaling: state.

REST的服务端是无状态的,这意味着服务器没有存储跨请求任何东西。这意味着不必是服务器之间(多)通信,使得它的水平扩展

The server end of REST is stateless, which means that the server doesn't have to store anything across requests. This means that there doesn't have to be (much) communication between servers, making it horizontally scalable.

当然,还有在在R小的奖金(重presentational)一个的负载均衡器的可以轻松路线到正确的服务器请求,如果你有很好的URL和GET可以去一个奴隶,而POST的去主人。

Of course, there's a small bonus in the R (representational) in that a load balancer can easily route the request to the right server if you have nice URLs, and GET could go to a slave while POSTs go to masters.

这篇关于为什么RESTful应用程序更容易扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆