简体   繁体   English

AppEngine,REST和服务器请求

[英]AppEngine, REST, and Server Requests

I've recently taken over a project that involves and iOS app connecting to a Restful web service for sending and retrieving data, and I find myself struggling with Server performance. 我最近接手了一个项目,该项目涉及和iOS应用程序连接到Restful Web服务以发送和检索数据的过程,我发现自己在为服务器性能而苦苦挣扎。

Since it's RESTful, the different kinds of data can be accessed from different URI endpoints. 由于它是RESTful,因此可以从不同的URI端点访问不同类型的数据。 When a user logs into the app for the first time (ignore the registration piece), the client must download all data for that user. 当用户首次登录该应用程序时(忽略注册件),客户端必须下载该用户的所有数据。 Since the data resides at different endpoints, the client makes a request to each, resulting in many requests to the same server to acquire all the data. 由于数据驻留在不同的端点上,因此客户端向每个端点发出请求,导致向同一服务器发出许多请求以获取所有数据。

My Question... is this a sound architecture? 我的问题...这是一种声音架构吗? The server ends up processing many requests just to get data for a single user. 服务器最终只是为了获取单个用户的数据而处理许多请求。 Wouldn't it be more prudent to have a single request that returns all the user's data? 拥有一个返回所有用户数据的请求会更明智吗? The server is appengine, and I'm trying to be more efficient in the use of it's free quotas. 该服务器是appengine,我正在尝试提高其免费配额的使用效率。

Thanks for any insights in advance! 感谢您提前获得任何见解!

Hard to answer without knowing how your data is structured. 不知道数据的结构很难回答。

If you're re-querying the same entities over those 6-7 requests, it's a bad idea. 如果您要通过6-7个请求重新查询相同的实体,那是个坏主意。 If you're querying different entities, you won't really have a significant difference in combining it into one query. 如果要查询不同的实体,则将其组合为一个查询实际上不会有明显的不同。

Having multiple requests can also allow your UI to "feel" more responsive as the user sees the page updating as results come in. With a single request, the user will be simply waiting until the entire request completes. 当用户看到结果进入页面更新时,具有多个请求还可以使您的UI感到“响应”更快。使用单个请求,用户将仅等待直到整个请求完成。

It sounds like whoever created the project initially decided to go with the cleanliness of the REST API by separating requests for different types of objects. 听起来好像是谁创建的项目最初决定通过分离针对不同类型对象的请求来遵循REST API的清洁度。 If you want to unify all user-related objects into one request, it's probably a much "messier" architecture. 如果要将所有与用户相关的对象统一为一个请求,则它可能是一种“混乱”的体系结构。

While there is indeed some overhead to having multiple requests, it generally isn't that big a deal. 虽然确实有多个请求会产生一些开销,但通常没什么大不了的。

There is a request time limit of 60 seconds. 请求时间限制为60秒。 Depending on the work that needs to be done for the single "return-all-user-data" request, this might play a role. 根据单个“返回所有用户数据”请求需要完成的工作,这可能会起作用。

Check the Google App Engine doc: 查看Google App Engine文档:
https://developers.google.com/appengine/docs/java/runtime#The_Request_Timer https://developers.google.com/appengine/docs/java/runtime#The_Request_Timer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM