Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should multithreading be used in microservices?

Should parallel programming be used in the development of microservices in case the microservices are scalable and, for instance, deployed as ECS on AWS?

If yes, what are the benefits of consuming more resources by one instance vs the same resources by N instances?

How does parallel programming match https://12factor.net/

P.S. to be more specific - should I conceptually use parallel streams rather than simple streams?

like image 969
Pasha Avatar asked Jan 27 '23 07:01

Pasha


2 Answers

Basically the link that you provided also provides answer to your question already

This does not exclude individual processes from handling their own internal multiplexing, via threads inside the runtime VM, or the async/evented model found in tools such as EventMachine, Twisted, or Node.js. But an individual VM can only grow so large (vertical scale), so the application must also be able to span multiple processes running on multiple physical machines.

https://12factor.net/concurrency

like image 186
Ivan Avatar answered Feb 02 '23 12:02

Ivan


Sure, imagine a microservice that needs to execute multiple independent calls to a dB or to other microservice and aggregate the results. As the calls are independent, they can be executed in parallel so that the total time is at most the time it takes to execute the slowest call.

like image 30
David Soroko Avatar answered Feb 02 '23 11:02

David Soroko