简体   繁体   English

对于用户交互度高的网站,是客户端渲染好还是服务端渲染好?

[英]For a website with high user interaction, is it better client side rendering or server side renderin?

I'm developing a website in which a user logs into their user account, enters data to a table (i'm using Tabulator) and then the data in the table is saved (i'm using MongoDB Atlas for data storage).我正在开发一个网站,用户登录到他们的用户帐户,将数据输入到表中(我使用 Tabulator),然后保存表中的数据(我使用 MongoDB Atlas 进行数据存储)。 The website has different subpages in which the data interacts with other data stored in another subpage (for example the website has a "Sales" and an "Inventory" subpages, so when the user makes a new sale the inventory will decrease by the sales amount).网站有不同的子页面,其中数据与存储在另一个子页面中的其他数据交互(例如,网站有“销售”和“库存”子页面,因此当用户进行新销售时,库存将减少销售额)。 Basically it's a website in which users constantly perform CRUD operations on their data.基本上它是一个网站,用户在其中不断对其数据执行 CRUD 操作。

Today the website is rendered on the client side.今天,该网站在客户端呈现。 Every subpage of the website has their own individual HTML file and individual Javascript file, with one Node file to handle all the backend communication with Atlas for all the subpages.网站的每个子页面都有自己单独的 HTML 文件和单独的 Javascript 文件,用一个 Node 文件来处理所有子页面与 Atlas 的所有后端通信。 I have only been using and testing the webpage from my local PC with one or two different user accounts, and it's all working fine the way it is (each user saves and works with their own data).我只使用一两个不同的用户帐户在本地 PC 上使用和测试网页,并且一切正常(每个用户都保存并使用自己的数据)。

Now, considering that i'm planning to deploy the website (to a domain or to Heroku), and potentially getting hundreds or thousand of different users, I've been looking into this options:现在,考虑到我计划部署网站(到域或 Heroku),并且可能会获得成百上千的不同用户,我一直在研究以下选项:

  • To keep using the simple client side HTML the way i've been using it.为了继续使用简单的客户端 HTML,我一直在使用它。
  • Rendering HTML as a response from Node将 HTML 渲染为来自 Node 的响应
  • Use a Template Engine from Node从节点使用模板引擎

Which option would you recommend considering the scalabilty?考虑到可扩展性,您会推荐哪个选项?

I would suggest taking a look at projects like nuxt js for the vue js framework or next js if you prefer the react framework.如果你更喜欢React框架,我建议你看看像 vue js 框架的nuxt jsnext js之类的项目。

AFAIK, they combine the best of server side and client side rendering. AFAIK,它们结合了服务器端和客户端渲染的优点。

These two frameworks are used for building a wide range of apps with various useful characteristics.这两个框架用于构建具有各种有用特性的各种应用程序。

Considering your needs, the universal applications features and the server side rendering may help you achieve the scalability you are looking for.考虑到您的需求,通用应用程序功能和服务器端渲染可能会帮助您实现您正在寻找的可扩展性。

Here's a tutorial from digital ocean about a simple app combining a django backend with a nuxt js frontend : How To Build a Universal Application with Nuxt.js and Django .这是来自数字海洋的关于将 django 后端与 nuxt js 前端相结合的简单应用程序的教程: 如何使用 Nuxt.js 和 Django 构建通用应用程序

This article will give you some of the benefits of using nuxt js for your web app. 本文将为您提供在您的 Web 应用程序中使用 nuxt js 的一些好处。

All that being said, it would be better not to worry about scalability for now.尽管如此,现在最好不要担心可扩展性。 This is one of the main reasons why startups fail .这是初创公司失败的主要原因之一 Focus on building a solution to your customers (users) problems first, and scale when you need it.首先专注于为客户(用户)问题构建解决方案,并在需要时进行扩展。

Yours is a good question, but it has an answer that's almost impossible to predict.你的问题是个好问题,但它有一个几乎无法预测的答案。 Taking a web app from a handful of users to a few thousand always uncovers surprising performance bottlenecks.将 Web 应用程序从少数用户增加到数千人,总会发现令人惊讶的性能瓶颈。

Will a bottleneck be on raw downbound bandwidth?瓶颈会出现在原始下行带宽上吗? Will there be a big gain to be had by slimming down your response to api calls and page requests?减少对 api 调用和页面请求的响应是否会有很大的好处? It's possible, but Heroku and other good host vendors do a good job of bandwidth.这是可能的,但 Heroku 和其他优秀的主机供应商在带宽方面做得很好。 Plus, https compresses data as it encrypts it, so repetitive html isn't as costly as it seems.另外,https 在加密数据时会压缩数据,因此重复的 html 并不像看起来那么昂贵。 So getting your server to render lots of html is probably acceptable.因此,让您的服务器呈现大量 html 可能是可以接受的。

Will some bottlenecks be at the app-database interface?应用程序-数据库接口会出现一些瓶颈吗? It's likely if large amounts of data and complex filtering criteria are in play.如果存在大量数据和复杂的过滤标准,则很有可能。 Every successful web app needs vigilance on its database.每个成功的 Web 应用程序都需要对其数据库保持警惕。 You'll have to add indexes or develop less elegant workarounds for problems you can't presently imagine.对于目前无法想象的问题,您必须添加索引或开发不太优雅的解决方法。

Will you have contention between processes that ingest your data and processes that use it?您是否会在摄取您的数据的进程和使用它的进程之间发生争用? Probably.大概。 But the details of that contention are hard to predict.但这场争论的细节很难预测。

tl;dr. tl;博士。 You have this thing working.你有这个东西在工作。 There's no need to rework it now.现在没有必要返工了。 Deploy what you have.部署你所拥有的。 Invite your users, and listen to them.邀请您的用户,聆听他们的声音。 Pay attention to how it performs, and concentrate your tuning and refactoring on areas where they prove necessary.注意它的性能,并将您的调整和重构集中在它们被证明有必要的领域。

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

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