Home > Net >  How work applications with I/O threads and working threads?
How work applications with I/O threads and working threads?

Time:09-15

I would like to know what is the best architecture style for creating application 1.) for server or 2.) when you want to create application from beginning (not necessary with server etc...).

My question is: "Do you know some source when I can read about usage of I/O threads and Worker threads?" As I can understand. When you need to create a good application it is good practice to separate I/O threads and Work threads. But I am not possible to find some good explanation with examples on web. Can someone write me how this architecture should work?

How for example Spring boot apply this? There are many examples with some usage of Spring boot on web. But I have not realized that I would find any example with separation of work of this two types of threads. Or just to describe some principles or examples.

Thank you

CodePudding user response:

Check on books like Pattern Oriented Software Architecture, especially volume 2: https://en.wikipedia.org/wiki/Pattern-Oriented_Software_Architecture

Understand how the Multiprocessing Module in Apache httpd works. Why are there three of them (prefork, worker, event)? How did they evolve?

Look at thread pool usage in application servers like Wildfly.

CodePudding user response:

The typical solution is to use some SEDA design: Staged Event-driven Architecture. Often each stage is made of reactors; so threads executing some event loop and moving tasks from one stage to the next (e.g. from socket read -> process -> socket write). E.g Hazelcast, Kafka, and Cassandra are good examples of that.

But recently, for high-performance systems, there is a shift to thread per core designs. So instead of having different stages, there is just a single stage. At this stage, all activities are performed: reading/writing socket, reading/writing disk, actual logic etc. So the processing of a single request is done on a single thread. The big advantage is that it scales a lot better and can provide superior performance. Scylla/Redpanda/Dragonfly are good examples of that.

  • Related