Jersey creates one thread per request. Is it possible to limit number of threads created on server side in Jersey Restful Web Services?
Firstly, i created a resource containing 4 methods viz., create, update, delete, read to perform operations on database.
Then i wrote a shell script which creates 10 process asynchronously and each process performs 100 sets(1 set = Create() + Update()+ delete() + read()) of CURD operations using cURL requests which were not asynchronous as i had to calculate total time taken for each cURL request.
I got result as:
Total time taken by 10 processes to complete is: 989.733 seconds
Average time of 10 processes is: 98.97330 seconds
When i increased the number of CURD sets to 4000, it failed. Then, i have created a resource which contains async method getData() in Jersey REST for better performance. Now, i intend to limit the number of threads created on server side in Jersey REST irrespective of number of requests fired from client side. Is it possible? Thanks in advance.
The details will depend on exactly how you are deploying your service.
As an example, the Jersey docs describe deploying to various different servlet containers. This implies that from the server's perspective the threading is handled by the container and so it's the container you need to configure.
Each servlet container will have a defined way of doing this: For example GlassFish