You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Justin Luster <ju...@sawtoothsoftware.com> on 2002/08/29 19:35:08 UTC
Filehandles
I'm using mod_perl 2.0 and Apache::Registry on a Windows XP machine. I'm using a load tester to test my Perl CGI program. I'm reading and writing to files and I'm using flock to control collisions. I keep getting an error when the load tester is going (5 concurrent users). It seems that the file handles are getting messed up. The script will write to files that I never write to but only read.
Does anyone know anything about flock and mod_perl? Have you ever seen file handles get messed up where things are being written to the wrong file?
Thanks.
Re: Filehandles
Posted by Perrin Harkins <pe...@elem.com>.
Chris wrote:
> XP is based on the NT Kernel, and should have a working flock. I believe In
> recent versions of 5.6.1 flock() is emulated on the 9x kernel as well.
> However this doesn't mean mod_perl supports it
It does actually, since mod_perl is Perl. Thanks for the flock
clarification.
- Perrin
Re: Filehandles
Posted by Chris <ch...@prather.org>.
> Personally I would suspect Windows in this case. I don't know about
> XP, but Windows 95/98/ME did not have a working flock. If XP is based
> on the NT code, it may not have that problem. Even so, I would try
> testing that first, or maybe asking about it on Win32 perl mailing
> list.
XP is based on the NT Kernel, and should have a working flock. I believe In
recent versions of 5.6.1 flock() is emulated on the 9x kernel as well.
However this doesn't mean mod_perl supports it, but I'm pretty sure (98%?)
Activestate and Win32 perl does. I've never flock-ed in my life (never had
a need) but I have been tracking Perl and Apache under Win32 for quite a
while so take all this with a grain of salt.
-Chris
Re: Filehandles
Posted by Chris <ch...@prather.org>.
> Thanks for responding so quickly.
>
> flock does work under Windows 2000 and above.
>
> The load tester that I'm using works fine with my script outside of
> mod_perl. My script works inside of mod_perl with only one concurrent
> user. When multiple concurrent users began hitting the script under
> mod_perl, using Apache::Registry or Apache::RunPerl all heck breaks
> loose. It seems that the file locking breaks down. Another thing that
> is totally bizarre is that stuff is being written to all kinds of files
> that I'm not writing to. Even my scripts themselves will sometimes have
> text appended to the end of them. Another problem is that Apache will
> give me an error message saying that it is trying to write to memory
> that is locked.
>
Could this be a threading issue? Are you using 5.6.1 or 5.8 with mod_perl
2? I know that mod_perl 2 is far from ready for primetime especially under
the threaded mpm's (which is what Win32 is forced to use). I use XP to
develop for a Linux mod_perl 1 architecture so I'm raipdly getting out of
my depth, but this sounds like the place to look.
I've never heard of a Win32 specific mod_perl list ... :(
-Chris
Re: Filehandles
Posted by Perrin Harkins <pe...@elem.com>.
Chris wrote:
> I think he said mod_perl 2 in his inital post.
Oops, you're right, I totally missed that. Sorry Justin.
- Perrin
Re: Filehandles
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Stas Bekman <st...@stason.org> writes:
[...]
> perl 5.8.0 internals are thread-safe, so does mod_perl 2.0-dev.
>
> By saying that perl is thread-safe, I mean that operations like push, =,
> /, map, chimp, etc. are thread-safe.
^^^^^
A thread-safe chimp; amazing! Try doing *that* in Java.
--
Joe Schaefer
Re: Filehandles
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Fri, 30 Aug 2002, Stas Bekman wrote:
> > I think he said mod_perl 2 in his inital post. Which I'm not sure really is
> > all that swift with concurrant requests under threaded mpms (Win32 is
> > limited to threaded mpms) ... least nobody seems 100% happy with the
> > threaded mpm performance of mod_perl 2 yet (Stas? Anybody? How's it
> > looking?)
>
> Caution: you are entering unchartered waters.
>
> first of all: you must use 5.8.0 with threaded mpms
[ ... ]
And, unfortunately for Win32, ActiveState has reportedly decided
not to release a perl-5.8 binary build in the near future, but
rather perhaps wait until a 5.8.1.
--
best regards,
randy
Re: Filehandles
Posted by Stas Bekman <st...@stason.org>.
> I think he said mod_perl 2 in his inital post. Which I'm not sure really is
> all that swift with concurrant requests under threaded mpms (Win32 is
> limited to threaded mpms) ... least nobody seems 100% happy with the
> threaded mpm performance of mod_perl 2 yet (Stas? Anybody? How's it
> looking?)
Caution: you are entering unchartered waters.
first of all: you must use 5.8.0 with threaded mpms
perl 5.8.0 internals are thread-safe, so does mod_perl 2.0-dev.
By saying that perl is thread-safe, I mean that operations like push, =,
/, map, chimp, etc. are thread-safe. Operations that involve system
calls, may or may not be thread-safe. This varies from OS to OS, and
even varies for various versions of the same OS.
e.g. localtime() is not thread-safe on platforms where asctime(3) is not
thread-safe. other problematic ones are readdir(), srand(), ...
there is another important issue. what some people are referring to as:
thread-locality. Certain functions executed in a single thread affect
the whole process e.g. if you chdir() in one thread, all other thread
now see the cwd of that thread that chdir'ed. Other problematic
functions are umask(), chroot(), %ENV...
Getting back to the Justin's question, it's quite possible that
thread-safety problems kick in. It could be that flock is not
thread-safe. But I think the real problem is with chdir(), because
Apache::Registry chdir()s to the dir of the script. Stop using
Apache::Registry and start using ModPerl::Registry, which doesn't
chdir(). Of course you cannot do any operations with relative path
anymore. Arthur Bergman is working on some solutions for chdir(), but
nothing was released so far. So you will have to wait or help Arthur to
finish his work.
So first try using ModPerl:Registry, which I expect will resolve the
issue. If that doesn't help, please supply a *short* script that
reproduces the problem. Which of course may not exhibit the same
behavior on a different platform, but at least we can do some sanity check.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Filehandles
Posted by Chris <ch...@prather.org>.
> Justin Luster wrote:
>> The stress tool that I'm using is from Microsoft and is a free
>> download.
>
> That isn't quite what I asked. Which version of mod_perl are you
> using?
>
>> There is a setting in this tool called
>> Concurrent Connections (threads).
>
> Regardless, mod_perl 1.x does not support multiple concurrent users on
> Windows. It will serialize those requests.
>
> - Perrin
I think he said mod_perl 2 in his inital post. Which I'm not sure really is
all that swift with concurrant requests under threaded mpms (Win32 is
limited to threaded mpms) ... least nobody seems 100% happy with the
threaded mpm performance of mod_perl 2 yet (Stas? Anybody? How's it
looking?)
-Chris
Re: Filehandles
Posted by Perrin Harkins <pe...@elem.com>.
Justin Luster wrote:
> The stress tool that I'm using is from Microsoft and is a free download.
That isn't quite what I asked. Which version of mod_perl are you using?
> There is a setting in this tool called
> Concurrent Connections (threads).
Regardless, mod_perl 1.x does not support multiple concurrent users on
Windows. It will serialize those requests.
- Perrin
Re: Filehandles
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Thu, 29 Aug 2002, Justin Luster wrote:
> The stress tool that I'm using is from Microsoft and is a free download. It
> is called Web Application Stress. There is a setting in this tool called
> Concurrent Connections (threads). As I mentioned before I am able to do
> this no problem under regular CGI with 10 concurrent users but when I run
> mod_perl all heck breaks loose.
I've tried a simple registry script that uses flock() (on WinXP),
as well as one that just prints out the environment variables,
using apache-2.0.40 and a recent cvs mod_perl-2 build. Using
ApacheBench as
ab -n ddd http://localhost/perl/script_name
(where 'ddd' is the number of requests to do), on my system, when
ddd exceeds about 1500 with perl-5.6.1, the tests hang, but
things are OK in this realm with perl-5.8. So this problem may
not have so much to do with flock(), but perhaps more to do with
threading under perl-5.6.1 on Win32.
If you're interested in comparing for your particular script,
there's a perl-5.8/Apache/mod_perl binary, perl-5.8-win32-bin.tar.gz,
at ftp://theoryx5.uwinnipeg.ca/pub/other/ - installation
instructions are in the associated .readme file.
--
best regards,
randy kobes
Re: Filehandles
Posted by Justin Luster <ju...@sawtoothsoftware.com>.
The stress tool that I'm using is from Microsoft and is a free download. It
is called Web Application Stress. There is a setting in this tool called
Concurrent Connections (threads). As I mentioned before I am able to do
this no problem under regular CGI with 10 concurrent users but when I run
mod_perl all heck breaks loose.
----- Original Message -----
From: "Perrin Harkins" <pe...@elem.com>
To: "Justin Luster" <ju...@sawtoothsoftware.com>
Cc: <mo...@perl.apache.org>
Sent: Thursday, August 29, 2002 1:44 PM
Subject: Re: Filehandles
> Justin Luster wrote:
> > The load tester that I'm using works fine with my script outside of
> > mod_perl.
>
> Does it work when running them concurrently under CGI?
>
> > When multiple concurrent users began hitting the script under mod_perl,
> > using Apache::Registry or Apache::RunPerl all heck breaks loose.
>
> Hmmm, which version of mod_perl are you using? If you're using 2.x, I
> can't help you there since I've never tried it on Win32. Maybe Randy
> will have some ideas. If you have 1.x, there is no concurreny under
> mod_perl -- requests are serialized.
>
> - Perrin
>
>
>
Re: Filehandles
Posted by Perrin Harkins <pe...@elem.com>.
Justin Luster wrote:
> The load tester that I'm using works fine with my script outside of
> mod_perl.
Does it work when running them concurrently under CGI?
> When multiple concurrent users began hitting the script under mod_perl,
> using Apache::Registry or Apache::RunPerl all heck breaks loose.
Hmmm, which version of mod_perl are you using? If you're using 2.x, I
can't help you there since I've never tried it on Win32. Maybe Randy
will have some ideas. If you have 1.x, there is no concurreny under
mod_perl -- requests are serialized.
- Perrin
Re: Filehandles
Posted by Justin Luster <ju...@sawtoothsoftware.com>.
Thanks for responding so quickly.
flock does work under Windows 2000 and above.
The load tester that I'm using works fine with my script outside of
mod_perl. My script works inside of mod_perl with only one concurrent user.
When multiple concurrent users began hitting the script under mod_perl,
using Apache::Registry or Apache::RunPerl all heck breaks loose. It seems
that the file locking breaks down. Another thing that is totally bizarre is
that stuff is being written to all kinds of files that I'm not writing to.
Even my scripts themselves will sometimes have text appended to the end of
them. Another problem is that Apache will give me an error message saying
that it is trying to write to memory that is locked.
Do you have any idea where I can go from here?
What it the address of the Win32 mod_perl mailing list?
Thanks.
----- Original Message -----
From: "Perrin Harkins" <pe...@elem.com>
To: "Justin Luster" <ju...@sawtoothsoftware.com>
Cc: <mo...@perl.apache.org>
Sent: Thursday, August 29, 2002 12:11 PM
Subject: Re: Filehandles
> Justin Luster wrote:
> > Does anyone know anything about flock and mod_perl?
>
> Yes. There is no problem with flock and mod_perl. However, if you were
> to open a filehandle in startup.pl and then use that same filehandle
> after forking, that could be a problem.
>
> Personally I would suspect Windows in this case. I don't know about XP,
> but Windows 95/98/ME did not have a working flock. If XP is based on
> the NT code, it may not have that problem. Even so, I would try testing
> that first, or maybe asking about it on Win32 perl mailing list.
>
> - Perrin
>
>
>
>
Re: Filehandles
Posted by Perrin Harkins <pe...@elem.com>.
Justin Luster wrote:
> Does anyone know anything about flock and mod_perl?
Yes. There is no problem with flock and mod_perl. However, if you were
to open a filehandle in startup.pl and then use that same filehandle
after forking, that could be a problem.
Personally I would suspect Windows in this case. I don't know about XP,
but Windows 95/98/ME did not have a working flock. If XP is based on
the NT code, it may not have that problem. Even so, I would try testing
that first, or maybe asking about it on Win32 perl mailing list.
- Perrin