-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]Stability needs to be improved with concurrent requests #4
Comments
@manhere : hello, I've just updated the issue template. can you please go through it below give the missing info when applicable. Thanks! PLEASE MAKE SURE TO READ THE RECOMMENDATIONS BEFORE OPENING A BUG REPORT: PLEASE READ THE FOLLOWING BEFORE OPENING A BUG REPORT: If you want to discuss a feature, improvement, or as a question, please create a discussion here: /~https://github.com/ESP32Async/ESPAsyncWebServer/discussions/categories/general If you have a crash, regression or found an issue, please give the following information:
Please post a complete decoded stack trace below in case of a crash (if applicable):
Please post some code, ino file, minimal reproductible use case (if applicable): |
board: esp32dev (esp32-wroom-32)
following attachment is a minimal replication project: thanks |
@manhere : and your progmem content is really all gzip encoded right ? |
yes ======================================================= please advise how to improve performance in case of large file downloads. thanks |
I found what is happening. @vortigont implemented in AsyncTCP and ESPAsyncWebServer a sort of throttling for responses taking a long time to commit in the network, because when serving files from SD cards (which is slow), it can block for a long time which can cause the esp32 to deadlock or trigger the watchdog. Refs:
So this is implemented in the chunk code also. See: 3d3456e#diff-646b25b11691c11dce25529e3abce843f0ba4bd07ab75ec9eee7e72b06dbf13fR388-R392
In our example, we used a 1024 chunk size to specifically increase the chunks. But in an app use case, you need to set the chunk size as high as your heap will possibly allow. 1k is really low! You are then serving a LOT of resources with small chunks, so you increase the concurrency level of chunk serving, which is slower because chunks are served in loops of small buffers. And they battle each other because you then have to serve several long requests at the same time. If you look at the logs, you should see a lot of:
It would be more efficient in your case:
|
@vortigont @me-no-dev : about the use case above... I think What do you think ? Should we just issue surround the code with a macro and the user activates the feature globally only if his app is doing some slow file serving ? Or should it be there by default and we add a macro to disable it ? |
@vortigont : I have opened PR #7 but I will let you check first in case you see a better solution... |
I would strongly advise to use built-in static handler for files on FS. |
@manhere : I added a macro flag: And the few people who need slow downloads with chunk encoding like file transfer from SD card will be able to switch it to 1 and have their application built in consequence of that. Note that the way your code is, it is still subject to some issues long-term because you are not really increasing response speed by increasing concurrency and lowering the chunk buffer amount: you are more increasing the workload on ESP size. If for example you happen to have some file download on top of that, you will run into issues. It could be better to server 4 requests consecutively with one chunk buffer of 8192k instead of serving 4 concurrent chunk request each with a buffer of 1024k. Imagine you have 2 or 3 users opening you page at the same time ;-) |
@mathieucarbou |
I was not able to reproduce that with esp32dev and Chrome, sorry... And with the information we have here in this issue there is nothing we can help with on that point. Note: for now, can you please update your
to test ? |
Thanks for the reply. Using the configuration you provided, the results remain the same. In my real project (using lvgl to refresh the screen to show some sensor parameters, sdcard to log them, webserver to provide a webpage to download the log file) I still can't set a higher chunksize, the webpage is completely unresponsive (at this point the output of ESP.getFreeHeap() is around 60000), only with the skeleton project(ESPAsyncWebServer ONLY) can I set the chunksize to 8192 and get better performance(js of size 169K is transferred in about 1 second, ESPAsyncWebServer@3.6.0 took 10-14 seconds). I don't have a lot of experience with ESP32, any suggestions for this situation? Thanks. |
In our recent tests we were able to serve dozens of megs files from SD card without any problems. @manhere could try to check two options:
|
That's what I was using in the beginning, and it was completely unavailable. Maybe it's because my program is running on low memory...lvgl takes up most of the memory and now freeheap has about 60000 available. it's really depressing. |
Did you try with ESPAsyncWebServer@3.6.1 ? |
@manhere : @vortigont is totally right also. Do not use chunk encoding for our embedded flash data. Use: If you have other issues with that, this is probably more related to few heap. send() will serve the data in chunk sizes optimized to match the client pcb free space (free lwip tcp buffer). So it can be more than 1024 like you have in your code. But whatever you do you are screwed by the low heap.
You really need to refactor your application. If you are using LVGL to display and it takes a LOT of heap, then, you need to create your website according to that. The current one is not suitable at all. Do instead like ESP-DASH team is doing: serve only one blob containing HTML + script + CSS, and then open a websocket connection to communicate with the UI. Avoid HTTP requests as much as possible, especially concurrent ones. |
@manhere : in See: #7 (comment) |
Description
it seems that big content(tens to hundreds KB), if js, css packaged together to a single page, output does not seem to be a big problem, but web page using external js, css ... result in multiple requests concurrently, then it will be jammed or return the truncated content.
files are stored in PROGMEM and gzip compressed. based on the description in the above paragraph:
AsyncWebServerResponse *response = request->beginResponse(200, "application/javascript", VENDOR_JS, VENDOR_JS_SIZE);
output is completely unusable: the content is truncated.
trying to use the chunked output:
barely works, occasionally the content is truncated.
trying to increase “CONFIG_ASYNC_TCP_QUEUE_SIZE” and “CONFIG_ASYNC_TCP_STACK_SIZE” does not help much either.
Thanks for your help.
Board: _esp32dev("flash_size": "4MB", "maximum_ram_size": 327680)
The text was updated successfully, but these errors were encountered: