javascript - 服务器端处理还是客户端处理?

标签 javascript ajax performance client-side server-side

我开发了一个比较网站,用于比较在印度在线销售的任何产品。目前,该站点完全是客户端:-

  1. Accepts user input.
  2. Makes 20-30 AJAX requests and fetches results from all the major online shops.
  3. Uses some client-side scripting to sort the results and show it in most appropriate way.

缺点:-

  1. My client side code is available to everyone. Its javascript.
  2. More prone to browser errors.
  3. Not robust.

使其成为服务器端后的缺点:-

  1. Considering the traffic of my website, server load will increase as it will be engaged with a client for longer time.
  2. Fetching values from various websites can take as much as 10s(at max).Server engaged for that time. Consider the load if I have 500 visitors/min at peak time.

优点:-

  1. My codes safe and secure
  2. Processing at client side will be minimum. Will work even on mobiles and other devices easily.

我想在实际实现之前分析这些问题。谁能建议我应该为我的网站选择什么?哪种方法更适合我?

如果我的问题不明确,请发表评论。

最佳答案

首先,这是一个很好的问题。

这完全取决于您的网站处理的数量和交易,如果您真的希望您的应用程序能够扩展,我希望您做对了!并从一开始就做好。

停止将您的业务逻辑放在客户端 ** 不要指望他进行比较时会占用最终用户的网络带宽 :) 也不要指望他拥有最好的带宽。

负载平衡您的服务器群 确保您的服务器群已正确负载平衡,并且比较是使用多线程而不是单线程完成的

缓存结果 ** 如果您在服务器端执行此操作,如果用户 a 和用户 b 请求相同的比较,您实际上可以从用户 b 的缓存中提取它,而不是再次执行这些请求。

可用性 向用户显示比较进度,而不是显示正在加载的旋转图像:)

希望对你有帮助

关于javascript - 服务器端处理还是客户端处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12596347/

相关文章:

javascript - 使用 jquery $.ajax() 调用 perl CGI

sql-server - 我可以使用 Hadoop 加速慢速 SQL 存储过程吗?

javascript - Angularjs:使用日期助手格式化 UTC 时间的时间戳

javascript - 不能让div去页面底部,CSS,HTML

javascript - JS获取指定类型的XML节点

ajax - 在 Access-Control-Allow-Origin 中为子域使用通配符

javascript - 为什么我不能在 ajax 成功中访问 $(this)

performance - 单核可实现的内存带宽

SQL 通配符 : performance overhead?

javascript - HTML 更改时验证限制复选框不起作用