How can I reduce the memory usage of uhttpd? Is my current situation the lowest possible?

Snipaste_2025-05-21_15-09-41
My uhttpd configuration is as follows:


I removed the luci-ubus option and here is the memory usage:

Are there other ways to further reduce memory usage? Also, why are there two identical processes? Is there a way to remove one of them?
I found that luci-base cannot be removed because I need util.lua to run normally.
If my current situation is already the lowest, will replacing other web servers improve the situation? I read an article before that said lighttpd is not better than uhttpd;
Thank you for taking the time to browse

You configured 2 instances - "main" and "mobile".

What version of OpenWrt are you using?

  • What does the phrase "lowest situation" mean?
  • What other web servers?

Low resource footprint I assume..

1 Like

yes but there are 3 processes;
image
openwrt 21.02-SNAPSHOT
Can I reduce the memory usage further? Given the current memory usage?
lighttpd?

yes ;Currently my device is often oom,So I have to further reduce the memory usage, and uhttpd is the process that takes up the most memory.

post the output of ubus call system board.

1 Like

It appears you are using firmware that is not from the official OpenWrt project.

When using forks/offshoots/vendor-specific builds that are "based on OpenWrt", there may be many differences compared to the official versions (hosted by OpenWrt.org). Some of these customizations may fundamentally change the way that OpenWrt works. You might need help from people with specific/specialized knowledge about the firmware you are using, so it is possible that advice you get here may not be useful.

You may find that the best options are:

  1. Install an official version of OpenWrt, if your device is supported (see https://firmware-selector.openwrt.org).
  2. Ask for help from the maintainer(s) or user community of the specific firmware that you are using.
  3. Provide the source code for the firmware so that users on this forum can understand how your firmware works (OpenWrt forum users are volunteers, so somebody might look at the code if they have time and are interested in your issue).

If you believe that this specific issue is common to generic/official OpenWrt and/or the maintainers of your build have indicated as such, please feel free to clarify.

If it is only for uhttpd, is there any way to optimize memory?

  1. Eliminate one of the 2 uhttpd instances. Or, even both. Then you still can directly edit /etc/config/....
  2. Use official openwrt for your board, if available, and do custom image.
  3. You might reduce / remove other processes. I.e. reduce cache of dnsmasq.
1 Like

Thanks for your answer;
I have two sections, two ports, and normally it should correspond to two uhttpd instances, right? But sometimes it turns into three uhttpd instances, which is normal? Why is there an extra one inexplicably?

ask the people who created the image, we can't tell if the behavior you're seeing is normal or not, since it didn't come from "here".

1 Like

Thank you all for your answers

You might try
listen_http list of port or address:port pairs #Notice ... list... !!!
To try, to use one instance of uhttpd only, listening on 2 ports. Dunno, how this works, though.

1 Like

Good idea!!!! I'll try it

If the cpu is mips you can make sure mips16 is used for comping binaries.

For Arm 32bit / v7 you can compile the kernel and binaries in thumb mode for reduced memory use.

You can make sure the kernel and the packages are compiled for size instead of performance though I think that's the default.

Also something to consider is just not keeping uhttpd up, just disable it in the startup and if you need web access just ssh in and temporarily enable it when you need it /etc/init.d/uhttpd start and turn it back off once you're done /etc/init.d/uhttpd stop

Thanks for the answer;
Regarding the compilation part, I will ask the relevant personnel for confirmation;
I think it makes sense to disable uhttpd, I want to monitor port 80 and start uhttpd when there is network access.

I am a lighttpd developer and I'd be interested in hearing something more detailed than a "trust me bro" without even a link!

lighttpd has many more features than uhttpd and most of those features are optional and in separate modules which do not get loaded if you do not configure them to be used.

lighttpd is resource efficient and can be further tuned for low-resource system and environments.

If you do not use web services frequently, lighttpd can optionally be started on demand and run from e.g. inetd or xinetd

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.