简体   繁体   English

在后端还是前端进行操作?

[英]Operations at backend or at front end?

In routine SPA development, there are operations which takes few milliseconds. 在常规SPA开发中,有些操作需要几毫秒的时间。 Now, as servers/backend are more powerful, should we perform such operation on backend and send processed data to clients or we should take advantage of distribution and off load this processing to clients? 现在,由于服务器/后端功能更加强大,我们应该在后端执行此类操作并将已处理的数据发送给客户端,还是应该利用分发功能来减轻处理负担?

eg If a process takes 100ms and we expect 5k hits 例如,如果一个过程需要100毫秒,而我们预计会有5k次点击

  • Server will require 5k * 100ms = 9 minutes roughly and increased memory while 服务器大约需要5k * 100ms = 9分钟,而在
  • Client may take 300ms on each device which may not be substantial. 客户端可能在每个设备上花费300ms的时间,这可能并不重要。

Question here is, how to decide what to process at backend and what to distribute and divide to devices? 这里的问题是,如何决定在后端处理什么以及如何分配和分配给设备?

I do recommend use back-end if there are operation on secure data. 如果对安全数据进行操作,我建议您使用后端。 If not - use front-end, because: 如果不是,请使用前端,因为:

  1. As you mentioned, it's additional load to server and server time 如前所述,这是服务器和服务器时间的额外负担
  2. If there is high load, then additionally to previous problem you also will have clogging channel of unneeded requests. 如果负载很高,那么除了先前的问题之外,您还将阻塞不必要的请求通道。

If you can do something without back-end - do it. 如果您可以在没有后端的情况下执行某项操作,请执行此操作。

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

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