File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Accessing pre-generated identifiers from a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing pre-generated identifiers from a Servlet" Watch "Accessing pre-generated identifiers from a Servlet" New topic
Author

Accessing pre-generated identifiers from a Servlet

Ujjwal K Gaurav
Greenhorn

Joined: Jun 02, 2012
Posts: 1
For my web application, I am expecting a peak load of about 1000 concurrent requests per second for a period of 5-10 minutes every business hour of the day. My web application needs to generate a 9 digit unique hexadecimal number, and send it as a response and also persist the same in the database.

As a solution, I am trying to pre-generate a Set of 5000 identifiers and keep it ready. During the peak load, I want my Servlet to simply keep popping out the generated the identifiers and use them in responses. When the generated Set count falls below 2500, I want to regenerate another 2500 unique identifiers and populate the same Set and keep it ready again.

Can someone please suggest a way to implement this?

Thanks in advance.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

Welcome to the Ranch!

If you persist it in a database anyway, I'd suggest to use a database mechanism for generating the IDs, such as a sequence or an autogenerated ID. You wouldn't finish handling the request till it's committed anyway, would you?

(I'm not sure about other databases, but Oracle's sequences can actually be configured to cache values exactly in the way you're describing. They are pretty fast.)
 
Consider Paul's rocket mass heater.
 
subject: Accessing pre-generated identifiers from a Servlet
 
Similar Threads
Creating Unique Id
WSIMPORT TO REFRER WEB APPLICATION WSDL AS END POINT
Forward servlets
Data Access Classes
ServletContextListener