question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance bottleneck with mono threaded Downloader Middleware

See original GitHub issue

Summary

There seems to be a performance bottleneck in the case where a Downloader Middleware is I/O heavy: I have a custom cache storage (very similar to FilesystemCacheStorage) which does some I/O. In the cases where the cache hit ratio is high, this cache becomes the overwhelming bottleneck.

Additional context

I tried playing with both REACTOR_THREADPOOL_MAXSIZE and CONCURRENT_REQUESTS but it seems that no multi-threading is taking place to invoke the cache middleware since it’s only ran from the main thread. I am not very familiar with Reactor thread pooling but I cannot find a nob to turn on multithreading at that level.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wRARcommented, May 29, 2020

You could always write async code in middlewares, using Deferreds.

There is no such thing as “reactor threads”. Native Python coroutines get wrapped into Twisted Deferreds.

i get non blocking I/O

Not necessarily. That’s why I wrote “Assuming your I/O-bound code is synchronous” and “asyncio doesn’t make your code asynchronous by itself”.

and muti threading in the middleware for free

You already have callInThread/deferToThread.

0reactions
yonromaicommented, May 29, 2020

Perfect, thanks so much for your help @wRAR

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core Performance Best Practices | Microsoft Learn
Tips for increasing performance in ASP.NET Core apps and avoiding common performance problems.
Read more >
Downloader Middleware — Scrapy 2.7.1 documentation
The downloader middleware is a framework of hooks into Scrapy's request/response processing. It's a light, low-level system for globally altering Scrapy's ...
Read more >
Tuning Performance Guide - Oracle Help Center
that the network is not becoming a bottleneck, or detect packet loss or other network performance issues. About Oracle Fusion Middleware Management Tools....
Read more >
Game Dev Guide for 12th Gen Intel Core Processor
Use the most performant cores first for single-thread and multi-thread performance. Ensure spill-over multithreaded work uses lesser ...
Read more >
(PDF) Improving Performance in the Network Storage Stack | Terry ...
High performance threaded data streaming for large scale simulations ... tions use single connections to access and utilize net- and work storage.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found