We'll first implement this using a separate thread that will resize all incoming images. After that, we'll improve the microservice with multiple threads using thread pools. In this section, we'll start to use threads to perform tasks in the background.
Interacting with threads
Synchronous or asynchronous?
In this book, we prefer to create asynchronous microservices, because these can handle a lot of concurrent requests. Not every task, however, can be handled in an asynchronous way. Whether we can use an asynchronous microservice depends on the kind of task and the resources it needs. Let's explore the difference further.