comparison of 3 common software architecture .
- Layer+message broker + worker
This is traditional way but still works for most of the projects launching now.
Layers: UI, service, Business, Data . will not go to each layer here .
the new friend come recently is message-broker and worker :
message broker could be considered as “request queue” .there is a ‘worker’ running to process the request in sequence . both could be clustered .could adjust the number of nodes .
the benefits is centralized the “business request” into one place ,improved system cohesion. and make the “request” and “process” async . they could be extended separately as well . each queue usually stand for each business request ,from business perspective ,system can be extended as well .
Pros :Development fast .business and application extensibility is good .
Cons :Not for huge system .
For : Middle-Small system .
Separate read and write which is query models and command models .
For read. directly get from cache or read DB.
for Write , sync Read DB with master use publication/subscription . or directly update both master and read.
before that ,command have to go into event sourcing .
Pros :Simple ,development fast .
Cons :Since there is no message broker in between .application and business hard to extend .
For : Small system or in a rush.
Recently getting popular . the benefits is totally decouple services and improve the cohesion of each service . on top of design there is a api gateway to get request from clients.
Pros : Extensible and maintenance .deploy separately .
cons : Development will be slow down , system complexity will increase .every service call goes through RPC, performance may get problem .
For : huge system .
There is no one architecture for everything .it follows business ,team ,etc .and architecture evolves as system various with business .For a simple application ,If wanted to apply Micro-service , will only get plenty of complexity and slow down project for nothing . steve McConnell said in <<Code Complete>>. control the complexity is the top one thing for programmer . the same for design .