Your program spawns two processes, process A and process B.
Process A does several tasks concurrently.
Process B listens to HTTP requests containing two integers a and b. For each received request process B creates a task that sends request to localhost port 1234 (served by process A). After the the task receives the response it it returns the second integer incremented by one.
- As one task it listens to HTTP requests on localhost port 1234. It always responds "OK" immediately.
- Then there are x additional concurrent tasks. Each of the tasks works as follows. It sends a HTTP request to localhost port 1235 (served by process B). The request contains two integers, task id, which is an unique integer between 1 and x and the second integer is 1. It does y these request in sequence. First integer does not change, the second integer is set according to what process B returns in the previous request by this task (thus the next request can be sent only after the response to the previous request is received).
Implement two versions of this program. In one version each task is run in its own thread, in the second you will use asyncio tasks (you should use aiohttp). Produce a short report that compares the performance of these two implementation (no longer than one page). Choose x and y appropriately for your experiments.
Note that in both cases you should be using two CPU cores (in the first implementation this is due to Python's global interpreter lock, in the second you just have one thread), of course the OS will probably be switching the cores. In the first case task switching is left to OS, in the second case to asyncio. Note that you need some basic interprocess synchronisation between the two processes so that process A start serving requests only after process B is running (see Python's multiprocessing library). You also need to be careful on when to finish the processes.
Send your solution to email@example.com. The first deadline is 1.5.2021 23:59:59. No code review is necessary this time. The solutions sent later will be accepted, however the number of points awarded may be reduced.