-
Notifications
You must be signed in to change notification settings - Fork 69
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
Really a use for select() ? #19
Comments
Thanks for the detailed proposal, Mark. I like it, except, as you say, we will be straying away from the simple design. How about the following model as an alternative:
Pros:
Cons:
Please let me know what you think. |
Having a proxy (ie. thread that will read/write between socket and buffers - or more likely pipes - passed to the child) is something I though of. In terms of design this gets closer to FastCGI for example (http server receives request, then pass it to another process that does the actual work). With both cases could be implemented with appropriate #ifdef (whoever compiles decides what fits best for him) that would be a lot of differences that could end making the code too complex. As such I would guess that before we decide on the appropriate method to deal with queries, defining a bit more the intended use for nope.c is required. |
What do you think of the idea of having two version? The "standard" version aimed at public websites, which was the original intention of doing this, and nope.c-embed for embedded systems. |
That could work, and if coded properly, we could just have a single file defining which version you're using (kind of the way Apache's MPM works, but more simple). In that case I can see a few patterns:
By the way we might want to support other methods of waiting for activity such as epoll(). |
Hi @riolet @MagicalTux , there are multiple networking patterns as MagicalTux pointed out:
Besides fork method, if we consider multi-threading, then the network patterns could be as follows:
|
The way nope.c works, each worker thread will wait for an incoming connection, then process it.
While this new method allows a single worker to process multiple requests at the same time, it is quite unlikely to happen - especially since the process() method will not return the processing of that query is done.
I would guess the purpose is to have multiple open sockets and wait for incoming data, but if one sender is very slow and sends fragmented request elements (ie. only "GET " at first), it will block that child while the child may have accepted other connections.
Anyway I believe it would make sense to either keep nope.c's original simple design (listen, process), or if we really want to do this right we could:
From there, the parent process could automatically increase the number of child processes should - for example - all children be busy, and do a lot of other interesting things.
Pros:
Cons:
The text was updated successfully, but these errors were encountered: