On Mon, Jun 28, 2010 at 11:25:03PM -0700, Sep Ng wrote: > I've been looking into building some thread intensive applications on > top of aolserver (both on 4.0.10 and 4.5.1) and from experience, it
Interesting. Perhaps tells us more about your applications, what led you here, etc. > seems that this maybe one of the easier points to get wrong and crash > aolserver. One of the great things about AOLserver is that it, in conjunction with Tcl, has a set of APIs that are MUCH better for doing practical multi-threaded programming than plain POSIX threads. This applies both when programming in Tcl and in C. So basically, I'm not sure what you mean. Anytime you write C code you certainly can 'do something wrong and crash the server', but that's not particularly difficult to avoid or fix. If for some reason that's still a severe concern, AOLserver, and especially C, probably aren't the right tools. (It is of course much harder to accidentally crash AOLserver from Tcl.) > 1. Is it advisable for aolserver to run a detached ns thread that is > supposed to run for the duration of the server? I don't see any reason why not. I've done it with "ns_thread begindetached", which worked just fine on both Solaris and Windows XP. > I was wondering about memory consumption and whether it's better to > let the thread perform the task and die after which the server > spawns another thread for a separate execution. That should of course work, but it's the exact opposite of standard performance-tuning advice for AOLserver. Every Tcl interpreter in AOLserver has its own entire copy of all Tcl library code. For that and probably (I forget exactly) other reasons, most (but not all) AOLserver threads tend to be pretty heavyweight, significantly more so than the underlying OS threads. So the standard advice is to reuse threads where feasible, and AOLserver is in fact specifically designed to automatically reuse connection threads. Rapidly creating and destroying many fat threads has a lot of overhead and will tend to give you lousy performance. > 2. I read that in Windows, thread destruction can cause instability > and possible memory leaks. Does this extend to other OS platforms? No. ;) FWIW, in my long-term but low-load use of AOLserver on Windows, I never had any particular instability problems. Given my code and how I had AOLserver's thread settings configured, there was probably very little thread creation and destruction going on, but that was essentially coincidental, I didn't design for it. > 3. I understand the general idea behind spawning threads with > aolserver, but ideally, I'd like to avoid the taboos on them, so any > idea about this is well-appreciated. Huh? What are you trying to ask here, and why? Spawning a new thread in AOLserver is easy, and I've never heard of "taboos" related to them. -- Andrew Piskorski <a...@piskorski.com> http://www.piskorski.com/ -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to <lists...@listserv.aol.com> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.