473,804 Members | 3,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating unique job id's for cgi script

5 New Member
HI,

I am creating a web server in which user will upload a file, in my cgi script using the upload method i am getting the file handle and writing the file in my hard drive, later am using the written file to do some process (in which two other files will be created and the names of those files are hard coded) and will list the output for the end user.

my question is if i have released this server globally, i may get lots of files at a time and i think it will crash, so to avoid that i wish to allocate unique job id to users when they upload the file, i wish to do like this and i am wondering how to do this in my cgi script or to be done somewhere.

please help me to do this?

Mopi.
Jan 17 '08 #1
4 2624
prn
254 Recognized Expert Contributor
Hi Mopi,

There are probably at least a billion ways to do this. Which you pick depends a lot on what you are trying to accomplish. Here's a simple one that should be moderately robust:

Assign IDs sequentially. You can start with any numbe you like. Create a file to contain the current job id. Your server process can then:
1) lock the file (flock).
2) open for read/write
3) read the current number
4) increment the number and keep track of that as your current id
5) save the new number
6) close the file
7) release the lock

Since the file is used only by your process, you should not need to worry excessively about whether your OS (windows?) will honor the file locks generally. Your process will. (The flock function reportedly does not work properly on Win95, but if you are using Win95 as a web server, you have much larger problems than I want to tackle.) The file will remain locked for only a very small fraction of a second, so this should not create any sort of server bottleneck. The numbers will be unique. Problem solved.

As I say, there are lots of other ways to solve the matter of assigning unique IDs. Many of them will work. You're probably much better off picking one that does check for uniqueness instead of just picking a random number and hoping that it will not cause a collision, but most of the time it won't. Timestamps are also good, but if you get a lot of traffic, then you had better take care to make sure that the granularity of your timestamp is sufficient.

HTH,
Paul
Jan 17 '08 #2
KevinADC
4,059 Recognized Expert Specialist
Good info Paul, but I am not sure it addressed his concern:

my question is if i have released this server globally, i may get lots of files at a time and i think it will crash,
Using a unique ID will not have any affect on how the server runs. It's doubtlful it would crash, but it might get very slow and be inaccessible if too many users are accessing the script. The http server setup is probably the place he needs to look to keep his server from "crashing".
Jan 17 '08 #3
prn
254 Recognized Expert Contributor
Good point, Kevin. I think he was referring to name collisions rather than actual server crashes due to load, but that's a possible interpretation too.

I guess he can clarify if needed.

Paul
Jan 17 '08 #4
KevinADC
4,059 Recognized Expert Specialist
Good point, Kevin. I think he was referring to name collisions rather than actual server crashes due to load, but that's a possible interpretation too.

I guess he can clarify if needed.

Paul

Hopefully he will clarify.
Jan 17 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2089
by: Phil Latio | last post by:
Have a database that records data taken in the field and was using an "auto_incremented" integer. I now want to distribute the database to others so they can record data then centralise all the data on one database so people can share records. However will an "auto_incremented" integer on it's own won't suffice? I suppose it might if that field didn't have to be unique but is that best practice? I was thinking along the lines of creating...
1
1779
by: Hasani \(remove nospam\) | last post by:
The way the system works is, you create a user control (ascx) that will be a template and must implement the interface IPageTemplate. You then create one or more user controls (ascx) that implement the IPageContent interface. A page (aspx) must then be created that loads (using Page.LoadControl) the page template, and the page content. The page content adds itself to the page template. The page template is then added to the aspx's control...
11
2324
by: rayala | last post by:
Hi all, I am having very weird problem in my Outlook I am running my web application from with in Outlook.I found a strange problem that it is creating different sessionId if i open a new window using window.open from with in my application.I am pulling my hair all along but no solution so far.Hope you guys can help me out. my application works fine when i run this in IE.It is Outlook2003
4
1926
by: Michel Verhagen | last post by:
Hi, I want to create a DTD in an XML file in memory. The XML file is created using the DOM in C#. I am new to all this, but couldn't find anything about creating DTD's using the DOM (well, I found some references but it doesn't tell me how to do what I want). Here's my code: XmlDocument xdoc = new XmlDocument();
1
6344
by: Danny Liberty | last post by:
I need some opionions on an issue here... Suppose I want to keep a collection of objects, each need to be uniquely identified by a number. This number has no meaning as long as it's unique, so it should be automatically generated for each new object. One more requirement is keeping the objects in the order in which they were inserted, not sorted by their ID. Considering the following options of implementation, which would be the best...
1
1796
by: Ronsol | last post by:
Hi, I want to import a XML file into SQL. But i can't find a good example to create an unique id from an higer element. I can create different tables, but a link between them not. I want to create an ID of the parent. Can somebody help me with a correct mapping schema? The xml file is : <?xml version="1.0" encoding="ISO-8859-1" ?>
13
40678
by: gamernaveen | last post by:
I am coding a script , where basically the user has to enter his name , choose file , file comments if required and upload. The file comments , name , filename will be stored in the database with auto_increment id. The file gets uploaded to the server too. The problem is I want to generate a 10 digit unique code , which makes it simple for the user to download the file , he just has to enter the 10-digit code , and my script will deliver the...
15
3959
by: Inny | last post by:
Hello, I found this simple js star rating script that I want to modify slightly. firstly I want to retain current vote , say 3 stars, untill its changed again. right now it resets to unvoted on refresh. I know you could use cookies but I also want to give it a unique identifier so that if i put it in my topic header templet, its unique to each topic (retaining whatever vote for each topic untill changed again) . perhaps this is not...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10578
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9152
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.