简体   繁体   English

写入Postgres的限制

[英]Limits of writing to Postgres

We've been directed to rebuild what is essentially a form that can have many potential sub inputs (ranging from 1 to 100 inputs). 我们已被指示重建本质上可以具有许多潜在子输入的形式(范围从1到100个输入)。

The change that has me concerned is that, we want to write each field for each input as it's typed, transported over Websockets. 我所关注的变化是,我们希望为每个输入写入每个字段,因为它是通过Websockets传输的。

For example if a user typed "hello", we would write to Postgres 5 times: for "h", "he", "hel", "hell", "hello". 例如,如果用户键入“hello”,我们会写5次Postgres:for“h”,“he”,“hel”,“hell”,“hello”。

I get that this is nice on the user end because it's saved as they go and they don't have to worry about "saving" the form. 我知道这在用户端是很好的,因为它随着它们的保存而被保存,他们不必担心“保存”表单。 However, I'm concerned that we will push up against issues with writing to Postgres so much. 但是,我担心我们会在写Postgres这么多问题上遇到问题。

We're using a Postgres instance with 4 GB RAM, 64 GB storage, 120 connections. 我们使用的是Postgres实例,具有4 GB RAM,64 GB存储空间,120个连接。

At what level of writes/second should we be concerned and what ways can we measure and mitigate against issues? 我们应该关注什么级别的写入/秒,以及我们可以通过哪些方式来衡量和缓解问题?

You should be concerned if you start having more than a couple of thousand writes per second. 如果你每秒开始有超过几千次写入,你应该担心。 You won't be able to support even substantially lower update rates unless you can make use of HOT updates (no indexes on the modified columns) because autovacuum wouldn't be able to keep up. 除非您可以使用HOT更新(修改后的列上没有索引),否则您将无法支持更低的更新速率,因为autovacuum无法跟上。

I think that the concept of storing partial user input in the database is madness. 我认为在数据库中存储部分用户输入的概念是疯狂的。 Your application should wait until input is finished, then verify that the data are correct and only then store it in the database. 您的应用程序应该等到输入完成,然后验证数据是否正确,然后才将其存储在数据库中。

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

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