Forums Register Login

Optimizing sevlet performance with a database

+Pie Number of slices to send: Send
Hello I have a design question.
Where is the best location on a servlet to access a database (assume a connection pool exists), and is database activity optimal when synchronized or left alone, for a high volume site?
When I say location on a servlet I mean, is it best to just write it in the service methods?
Or
Is it better to write it in its own method outside the service method?
Or
Is it better to write it in its own class which is instaniated and called within a service method or in singleton class which is shared among the site?
And is performance boosted if synchronization is used?
+Pie Number of slices to send: Send
If your application follows an MVC pattern (and it should), database access should be abstracted away from the servlet, which is part of Controller, into classes that are part of the Model.
Synchronization never improves performance. You synchronize to prevent thread safety issues, not to boost performance.
+Pie Number of slices to send: Send
So you think it is best to leave them in seperate classes and instaniate them in the service classes?
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 699 times.
Similar Threads
multithread in servlet container
J2EE Recommended Reading
Is this considered MVC?
To Nikhil Pendharkar for IBM 287
need support to implement this idea
Is my servlet threadsafe?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:01:46.