Re: GLIB for a webserver



Hello,

- On Apache ARP project, they said they created it instead of using
glib because the lack of IPC functions like memory mapping.
This makes no sense since they could use glib and also write mmap
functions...
   Well, that's what I thought too. That's why I made the decision to
ask here if it would make sense.

- In some forums, people were complaining about the fact glib aborts
when memory allocation fails, which is bad for a 24/7 running web
server.
A robust Web server would probably have a framework that restarted
components as needed; Apache already does some of this with "workers".

The main problem with memory allocation comes when someone else's
process is using all the memory.

   My server code is too smal yet to compare, but it is being already
planned to do it. I start each application hosted by my server in a
different  process, so I will be able to restart it if the process
segfaults or quits for some reason. But I think like this (please tell
me if you agree or not):
 - If the server itself (my code) seg fault, so it should stop. I
should solve this by fixing my code, not by writting whatdog for it,
as I explained above;
 - However, as you said, if someone elses code (like applications or
service plugins in my case) segfaults, my server should be able to
restart the applications as needed.
    But I pay a price for it. As this is implemented with IPC and I
need multiple processes, I will spend more computer resources
(CPU/memory) to deal with it, to make it more reliable. Pays the way,
but I imagine it's where it will need more optimization.

If you are writing a new Web server (why?) glib is probably fine.

   By this affirmation, I understand glib is not only a basis for
desktop app, right? Good! I will like to use it.
   The reason why I am writting is a bit of Linus Torwalds fault. :D
After reading hundreds of messages on a GIT mailing list on a thread
he started (http://article.gmane.org/gmane.comp.version-control.git/57918),
I realized I agree with him. My intention is not exactly to write a
web server, but an application server, like JBoss
(http://www.jboss.org/), but in C. I use Java app servers on my
day-by-day work, but just because people pay me to do that. I _hate_
Java resource consumption and I think it should exist a FAST, easy to
use alternative in C.
    It's my pet project, by now.

Don't fight it, though. There's no portable way to find the system's
free memory, and even if there were, it wouldn't help -

   if (amount_of_memory < amount_available) {
        // imagine that after that test succeeds,
        // your program happens to get swapped out,
        // and another program allocates all of memory

        allocate_memory(); // fails
   }

   You are right. I haven't thought about it.

So it's better to assume that things will fail. Robustness does not come
from avoiding failure - it comes from recovering from failure.

This paragraph made me think a lot (thanks for it!). I fully agree
with you if I think on others' processes, but talking about the server
itself... Need to think. Anyway, the fact glib exits when memory
allocation fails wouldn't stop me from using it. I am sure there is a
way of solving it, one way or another. Of course finding it will be a
bit hard... But will think carefully on what you've said.

For a Web server that may just mean restarting. Sure, some users will
have to reload Web pages; if that's actually a problem, use persistent
storage to record state.

   In the case of my server, each request may result in an open
database connection and possibly a started transaction. Stop all
current transactions because the server is on its limit is something
that might happen, but I don't consider good. I can recover from that,
but finding a way of not letting that happen would be preferable.

Apache and IIS are fairly large codebases for a reason, though -- a
secure reliable production Web server would have a lot of catching up to
do.
    Sure, but I have no intention of replacing it. I plan to let my
server work as an apache or NGinx plugin someday. My project is much
more like Phusion Passenger (http://www.modrails.com/) or JBoss, but
for C development.
    Of course there will be a lot of catching up too, but differently
of these servers, that focus mostly on how to service something in a
reliable way, I want to focus on providing an easy to use API for the
application developer, as my server hosts applications. I would
provide services like message queueing, database connection pools,
load monitoring, etc.
    Here is where I found the power of gnome would help me a lot. By
using the APIs provided by gnome, as GDA, GLib itself, GIO, etc., the
application developer would have a portable, powerful and easy to use
API at his/her disposal, to write server side apps and application
middleware.
    Unless all these libs are supposed to be used only by desktop apps
and I shouldn't be trying to use it for middleware... :D

But, it's fun writing Web servers :-)
   you bet!  ;-)

Best regards,
-- 
Marcelo Elias Del Valle
http://mvalle.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]