My web service server side application serves the stored procedures for the request from different users. I am opening and closing the ADO Connection for each request. Is it advisable or can any one suggest a better method? And help me in session management. Thanks in advance.
2 Answers
ADO supports connection pooling, so enable it on your Connectionstring property of TADOConnection

- 10,992
- 7
- 43
- 68
-
+1 The best is to reuse an existing connection between calls on the server side, but connection pooling is a 2nd best solution in order to improve speed. – Arnaud Bouchez Sep 21 '11 at 11:38
-
Thanks for your information. I do not know how to reuse the previous connection. Please help me – baskaran a Sep 22 '11 at 06:23
Creating a new connection from blank can be very time consuming (e.g. more than 1 second with a remote Oracle connection), therefore is to be avoided like hell for a service application.
IMHO the best solution (from the performance POV) is to maintain one DB connection per server thread. So it will depend on your HTTP service implementation.
Connection pooling is also available if you don't want to deal with threads, as Mohammed wrote in his answer.
Consider also using server-side caching of answers. If you know that the result will be consistent, you should better cache it on the server side and share it among clients. Of course, this is worth developing only if client requests may share.
About session management, what do you want to know? I guess this is about Client sessions. For a web service, the main usage is to implement a session via cookies. See this SO answer about authentication of a web service, for other possibilities. IMHO a RESTful approach (i.e. stateless) is worth considering for a web service.

- 1
- 1

- 42,305
- 3
- 71
- 159