Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple users accessing a script at the same time?? 1

Status
Not open for further replies.

andyros

Programmer
Jul 12, 2005
42
GB
Hey guys

I've built a basic shop system as a small project, in object orientated perl ;)!

I was just wondering what happens when multiple users call the same functions at the same time?

I have cgi scripts at the front end, and they use generic back end functions, i could have 5,10,15 users calling this cgi script at the same time and thus using the same functions from a back end module.

Will perl handle this? I have output to STERR and STOUT, i am right in that this can only be opened for one call??

just curious really!
thanks
andy
 
The whole question is not simple to answer. It depends upon many things but assuming that your OO perl uses scoped data and it does not use any resources that need locking (such as common files) then you should be fine.
If you want a more detailed answer then you might like to post some more details about what you're doing.


Trojan.
 
its essentially a really simple shop system, with an sql table to simulate products.

Basically its storing products in xml files which are categorised into sub folders. A new product is a new xml file so theres never any two attempts on one file.

The front end cgi scritps basically pass mysql values back and forth to retrive category information.

All files are user defined really, there are no files in which are universal. But there definatley will be multiple attemtps at an mysql connection at any one time.

What do you mean by scoped data?

andy
 
that should read the xml files are split into sub folders which represent categories.
 
I mean "my" data or dynamically generated data. NOT global variables.
In other words you create an instance of the object as "my $object = new object()" and your "new" method allocates storage for the instance dynamically (usually as an anonymous hash: "my $self = {};").
The DB connections should be fine but you need to be aware that if you need to write to the DB at any time you need to make the write cycle atomic (all related table writes for one record in some form of transaction).
BTW: Is there any risk that 2 users could be trying to create the same file at the same time? Where are the files stored? How are the filenames generated?


Trojan.
 
instances of an object are created with a new method and are stored as an anonymous hash ($self = {};) as you suggested. Is this ok?

I though about writing to the database at the same time, so i've created a cycle file which is set up as a cron job, this cycle file is a perl script which has system calls to other smaller scripts which belong to each write instance, and contain the write method itself...these are in turn called by system("perl some/perl/routine/routine.pl")

Am i ok with this method? There isnt a need really to write to the database stright away, i can wait.

There isnt a risk that two users could create the same file. Each user has a folder within

main system/store/userid/*users store space*

So two users will never write to the same file. There is however the chance that one user may click something twice (this is in the future, not implemented yet) which would generate the system trying to write to the same file. I was thinking of putting a time dealy on the creation of a file? as there isnt really a need for it to be instant.

thanks for your help, eased my worries about. I'll let you know when i get the server sorted how everything interacts.

PS. Is there a better method of writing an error log, currently all my errors are sent to STDERR then sent to a file with a unix command. I suppose this will not work if multiple functions are trying to write to STDERR?

thanks
andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top