知识卡片

普通读书笔记卡 · 5383

单写者减少读写协调

理解等级:高级

多个线程协调写同一目标时,争用与同步可能使吞吐低于单写者。可让工作线程把数据提交队列或环形缓冲区,由一个写者批量落下,既减少互斥协调,也合并I/O次数。适用前提是写入可集中且顺序、积压与失败策略清楚;单写者并非在所有负载都更快,需测出协调成本是否真是瓶颈。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 服务端架构 · 查看原书依据

      A single writer often performs better than multiple coordinating writers when writing to the same source. In such cases, it is better to submit data from multiple threads to a queue or LMAX Disruptor ring buffer and write the data using a single writer.

    参考来源

    - 位置:《Software Architecture and Decision-Making》第11章《Server Architectures》(来源项目:book-sources;源文件:extracted/Software Architecture and Decision-Making Leveraging Leadership, Technology, and Product Management to Build Great Products… (Srinath Perera)/_epub-src/ch11.xhtml) - 结论依据:摘录说明多个线程协调写同一目标时,争用与同步可能使吞吐低于单写者。其余条件结合本章相邻例子与取舍说明,数字示例不作当前性能承诺。 - 原始内容:A single writer often performs better than multiple coordinating writers when writing to the same source. In such cases, it is better to submit data from multiple threads to a queue or LMAX Disruptor ring buffer and write the data using a single writer.