epoll-server
websrv
epoll-server | websrv | |
---|---|---|
3 | 1 | |
8 | 10 | |
- | - | |
3.3 | 10.0 | |
7 months ago | over 7 years ago | |
C | C | |
- | GNU Affero General Public License v3.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
epoll-server
-
Notes on my incomplete JIT compiler
I also have some epoll server code at https://github.com/samsquire/epoll-server
-
Ask HN: Resources for Building a Webserver in C?
You might find my epollserver interesting.
It multiplexes multiple clients (sockets) over a thread, so you can write an event loop in each thread and serve far more requests per thread than you could if it was one thread per client or one process per client.
https://github.com/samsquire/epoll-server
-
Epoll is fundamentally broken (2017)
I wrote an epoll echo server that multiplexes multiple network connections over threads (multiple users per thread)
https://github.com/samsquire/epoll-server
I also have a 1:M:N (1 scheduler thread, M kernel threads and N lightweight green threads) multithreaded userspace scheduler which multiplexes lightweight threads onto kernel threads and can preempt hot loops with minimal overhead. I rely on the fact that you can change the looping variable from another thread if you use a structure. Preemptive interruption is very useful for the illusion of multitasking. That's why I call it a userspace scheduler.
I think the epoll-server which is kind of similar to what libuv does and the userspace scheduler could be combined into an application server.
I also wrote a multithreaded actor implementation in Java. Threads can communicate with each other between 60 million - 100 million messages a second. The epoll-server uses a multiconsumer multiproducer lockless RingBuffer.
https://GitHub.com/samsquire/multicersion-concurrency-contro...
I think the core fundamentals of building a performant application server should be done once and reused for each application.
I want to also split the threading used by recv and send of a socket so that we have a 1:R/S per socket:N scheduling (1 scheduler thread, 1 Recv thread, 1 send thread per socket). So you can send while you receive and receive while you send. True multiplexing!
websrv
-
Ask HN: Resources for Building a Webserver in C?
"Write a tiny web server in C" was a standard exercise when I was in high school, and later again in university. I think I did that at least 3 times as an assignment so far.
Back in 2015, I dumped the result of the University exercise here: https://github.com/AgentD/websrv and kept adding to it for fun.
The HTTP 1.x protocol itself is pretty dead simple (if you ignore chunked requests/responses and such) and the more interesting part was actually the socket code.
Back in school, our teacher had us write a simple forking server and consult the corresponding man pages (man 2 socket, man 7 socket, man 7 tcp). It was an acceptable minimal solution to not even look at the client request, respond with a static string containing a dummy response header and HTML page, which absolutely works. Bonus points for parsing the request path and sending a file back, more extra points if the path was a directory and your server sends back an "index.html" file, further points if it instead generates an HTML directory listing on the fly.
When I visited our former teacher a couple years ago, he had modified the exercise somewhat. He brought a Beagle Bone Black with him to class, with a bunch of I2C sensors attached to it, and the extended exercise revolve around reporting temperature/humidity/... to the browser.
So, for "resource" I recommend the HTTP example on Wikipedia, as well as "Beej's guide to network programming" (as have others), as well as the man pages for quick reference.
What are some alternatives?
libreactor - Extendable event driven high performance C-abstractions
picohttpparser - tiny HTTP parser written in C (used in HTTP::Parser::XS et al.)
preemptible-thread - How to preempt threads in user space
Mongoose - Embedded Web Server
assembler - amd64 assembler
loti - Lord of the io_uring: io_uring tutorial, examples and reference
garbage-collection
compiler - an incomplete toy barebones compiler backend for amd64 x86_64 in Python and an incomplete JIT compiler written in C
libuv - Cross-platform asynchronous I/O