What is the industry/production grade solutions or if you have already any experience please share it. Thanks

  • A Phlaming Phoenix
    link
    fedilink
    arrow-up
    3
    ·
    11 months ago

    To build on this (and I also use Postgres, so I’m assuming MySQL/MariaDB are similar), there is almost certainly a metric emitted by the DBs that can tell you how long that lag is between initial write and replica updates. That would be the thing to monitor to detect the specific problem where replication lag creates application lag.

    Also worth mentioning that horizontal scaling can solve some problems, but there are a few major configuration items to check that will improve performance across all the replicas. Off the cuff:

    • Properly index your tables
    • Build on hardware big enough to keep indexed data in memory
    • Don’t use the MyISAM engine with MySQL since it has a bunch of performance and locking problems. Upgrade to InnoDB.
    • Optimize your queries. Horizontal scaling won’t give you much improvement if you’re doing full table scans or something like that. ORMs can produce some pretty ugly SQL sometimes. Consider writing your own queries that are better optimized to make use of your indices.