My question is not about how to do this, it's whether it would be done.
(我的问题不是关于如何执行此操作,而是是否会执行。)
My application subscribes to a websocket for real-time data and writes to a postgres database. (我的应用程序订阅了一个用于实时数据的websocket,并写入了一个postgres数据库。)
Most of the time writing the incoming data doesn't have a high enough volume that this question matters (think equivalent to hundreds of records inserted per second). (在大多数情况下,写入传入数据的容量不足以解决此问题(请考虑相当于每秒插入数百条记录)。)
However during certain periods of the day the volume can spike and be sustained for multiple minutes, in which case I'm concerned that insertions might cause some websocket buffer to fill up.
(但是,在一天的某些时段内,音量可能会飙升并持续数分钟,在这种情况下,我担心插入操作可能会导致一些websocket缓冲区填满。)
So the question is: what exactly is the tradeoff that should consider when deciding whether to have the inser to postgres block the main loop, versus have the main loop pass the data to a separate worker thread which does the inserting?
(因此,问题是:在决定是否让插入程序来postgres阻塞主循环,而让主循环将数据传递给进行插入的单独工作线程时,应该权衡哪些考虑呢?)
(I understand a big downside of threads is increased complexity) ((我知道线程的一大缺点是复杂性增加))
ask by jdhf translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…