From last week, I am thinking of a super light weight web server.
There are many choices:
LuCI + uhttpd, goahead, mini-httpd, etc…
But none of them is perfect for me:
1. cgi part use too much resource.
Fork new child process to deal cgi, and dealing code with Lua. Calling script to create the html page. If I need update frequently, such as video, the board will die for out of memory or cpu 100%.
2. memory control low efficiency.
They call malloc for every memory request. For small memory device, such malloc is pain. It will generate tons of memory fragment, and the core have to arrange them, costs lots of resource.
3. unnecessary optimisation.
We just has one core, so whatever the optimisation you do, remember the most effect way is to make the app run in one thread.
Such on board web server do not have to deal with many people request same time, so use why use pthread? Looks like the reply time is shorter, but underground it costs two times of CPU time, if the load is heavy, it is twice slower.
4. take too much disk(flash) space.
goahead, after I compile it, the size goes to 850KB, and even not contains its dependency library.
So same reason as I make VoCore, I write something looks better to me.
1. advanced memory control.
Only 12KB or even lower memory request. Self maintain memory, do not create memory fragment.
2. optimisation for one core cpu.
The full application only have just one thread, no switch cost.
3. cgi write in pure C code.
This makes it more effective, no middle layer. Pure server, client mode.
4. super fast.
deal 60~80/sec request on VoCore.
5. minimised dependency
Only basic C library is necessary. Do not need pthread, libdl, etc.
6. small executable file size.
After compile, it is 33KB, and do not need addition library. That’s all.
7. source code in one file.
I like sqlite3 style, so I make all files into one file, easy to compile.
This VoWebServer is very “embed”, of course, it is just a new project, many bugs have to be fixed, at least, we have one more choice. 🙂
Here is the source code, once I feel happy about it, will upload to github.
compile it by one line:
cc -g voweb.c -o voweb
Compiled one for VoCore: voweb
run it like this:(put some htmls to /var/www/html, it will get index.html)
voweb 8080 /var/www/html
Then open 192.168.61.1:8080, you will find the page 🙂
Test cgi function: http://192.168.61.1:8080/cgi-bin/love?VoCore
(cgi-bin folder do not exists)
My experience on other RT5350 based wifi router with 32MB ram running uhttpd+luci is just fine. Luci is rich feature web admin tool , I don’t see it is good idea to be replaced. The spec of vocore looks well for luci.
Your voweb is very suitable for uboot. It is only required a few form feature. It is very easy to integrated with your solution.
I cast my vote on Luci.
Why?
1. do not reinvent wheel
2. much richer funcionality
3. It WORKS OK on VoCore
4. It will move forward with more features in the future (actively developed)
5. it’s better to coordinate efforts, than to start from start
Please keep it 🙂
Of course I will keep LuCI. Just one more choice if you have heavy load. Such as camera, you will find LuCI takes too much resource.