• 请不要在回答技术问题时复制粘贴 AI 生成的内容
mortonnex
V2EX  ›  程序员

主从库同步延迟引起的问题

  •  
  •   mortonnex · Oct 24, 2018 · 3049 views
    This topic created in 2830 days ago, the information mentioned may be changed or developed.
    比如插入一条数据,然后查询,如果走从库,那么会有可能查不到,从而引发问题

    如何破?
    10 replies    2018-10-24 17:48:54 +08:00
    justseemore
        1
    justseemore  
       Oct 24, 2018
    - -,要看具体需求吧?
    88250
        2
    88250  
       Oct 24, 2018
    基于数据库复制的技术架构讨论 https://hacpai.com/article/1465278948107
    hadesy
        3
    hadesy  
       Oct 24, 2018
    如果是即时查询,需要路由到主库进行查询,这个一般的中间件都支持,或者封装到事务中,事务都会只在主库执行
    nosay
        4
    nosay  
       Oct 24, 2018
    视情况,决定是主库或从库提供数据。
    sununiq
        5
    sununiq  
       Oct 24, 2018
    重要数据一定的时间内读已知写,非强一致性需求数据还是可以从从库读取,最终一致性保证
    nobject
        6
    nobject  
       Oct 24, 2018
    可以将新插入的这条数据可以缓存一小会,然后过段时间自动失效,读的时候先读缓存,然后读从库。
    jeffsun
        7
    jeffsun  
       Oct 24, 2018
    如果是 mysql,可以半同步,全同步,不过会降低性能
    aqqwiyth
        8
    aqqwiyth  
       Oct 24, 2018
    中间件级别的需求. 比如延迟达到多少秒, 强制走主库查询
    chenxytw
        9
    chenxytw  
       Oct 24, 2018
    配置全同步 0 0
    xiaoxinshiwo
        10
    xiaoxinshiwo  
       Oct 24, 2018
    包含读和写的走主库,纯读的才走从库啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   951 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 22:10 · PVG 06:10 · LAX 15:10 · JFK 18:10
    ♥ Do have faith in what you're doing.