Search code examples
asynchronousweb-applicationsconcurrencyarchitecturecqrs

How is a web app is affected by concurrency?


Can someone please explain how concurrency affects a web application?

Anything helps! Thanks.


Solution

  • This is a super broad question but the common sources of concurrency errors from base of app up are:

    • DB Level (MVCC)
    • Runtime Level (programming language, concurrency model, threads, locks, race, conditions, etc)
    • Web server level (Multiple client requests on the same endpoints at the same time)
    • Logical: CQRS (Eventual Consistency, Writes and reads are separate, reads can be stale/lagged)
    • Logical: Distributed transactions (Imagine having a read cache like redis and a store like mysql, how do you guarantee these are in sync?)

    I can't recommend Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems highly enough which provides a foundation into all the important concepts your concerned about!


    A concrete example using CQRS:

    • There is a DB store
    • There is a single Writer
    • There is a single Reader

    A transaction makes a request to persist information to the writer and then immediately reads back from that reader. Depending on your CQRS implementation it's possible there are only eventual consistent guarantees between writes and reads, meaning the read may not see the just written data! Of course this may ore may not be an issue depending on your client.