Not enough web workers on app?

Hi, I made a Django app with 2 web workers. I thought that web workers would mean that the website could handle "web workers" amount of requests at the same time, however, while I have 2 web workers and I know that no one else is connected to the website, if I try to open the website at the same time from 2 different tabs, the second one has to wait until the first one loads to start loading.

If I try to open more tabs, each one has to wait for the previous to load. Is there a way I can fix this?

Web workers are processes available for your web app to process the incoming requests. Each worker will however process the incoming requests in required time -- so if, for some reason, your site takes 2 or 3 seconds to load, you will need to wait at least 2 or 3 second every time. So number of workers may increase your app performance when there are lots of requests comming in. Workers don't speed up processing the singe request though. Try to establish what is slowing down your site (that could be a data base query, connecting to an external service, loading big files etc.).

Here are some help pages that you might find useful:

I think the problem is not that my page is slow. For example it takes 5 seconds to open a page. If I open 2 tabs of the same page, the first takes 5 seconds and then the second tab takes 10 seconds, since it waits for the first tab to load, and after it ends, the second starts loading.

The same happens with more tabs. If I open 10 tabs, then 10th tab has to wait for all the previous 9 to load. If I have 2 workers, shouldn't it at least load the pages 2 by 2? Why is this happening?

Your website definitely is running with two worker processes and can handle two concurrent requests.

If you're sure that no-one else is using your site, perhaps each page actually triggers two requests to your site (maybe due to an iframe, or some kind of JavaScript request)?

Alternatively, perhaps you have some kind of code that is locking some global state while the first request is being processed, so that the second one is waiting on it even though it's in another worker. For example, if you're using SQLite as your database, one worker might be performing an operation on the database and locking it, so the other would be waiting for that to complete. If you are using SQLite, I'd definitely recommend switching to MySQL because that has much better handling of concurrent queries.

I am using Postgres. Do the db queries go to the second worker? Or maybe the problem is that I am using different tabs from the same device? Because I tried from a different one at the same time and they completed loading at the same time, so maybe that was my problem.

I'm not sure what you mean by "going to the second worker" -- opening a site in a browser often involves multiple requests (that not includes static files). One worker processes one request. You can look at this by opening "Network" tab in developers tools in the browser and refreshing the page -- you will see how many requests are performed and how much time they consume. You also can, for debugging purposes, check your access logs, to check how many requests were perfomed in the periods of time that you were testing your app, and how much time did they consume.