简体   繁体   English

Delphi 2007 Web服务服务器端应用程序

[英]Delphi 2007 Web Service Server side application

My web service server side application serves the stored procedures for the request from different users. 我的Web服务服务器端应用程序为来自不同用户的请求提供存储过程。 I am opening and closing the ADO Connection for each request. 我正在为每个请求打开和关闭ADO连接。 Is it advisable or can any one suggest a better method? 是明智的选择还是有人可以建议一种更好的方法? And help me in session management. 并帮助我进行会话管理。 Thanks in advance. 提前致谢。

ADO支持连接池,因此请在TADOConnection的Connectionstring属性上启用它

Creating a new connection from blank can be very time consuming (eg more than 1 second with a remote Oracle connection), therefore is to be avoided like hell for a service application. 从空白处创建新连接可能会非常耗时(例如,使用远程Oracle连接要花费超过1秒的时间),因此对于服务应用程序,应避免像地狱般被避免。

IMHO the best solution (from the performance POV) is to maintain one DB connection per server thread. 恕我直言,最好的解决方案(从性能POV来看)是每个服务器线程维护一个数据库连接。 So it will depend on your HTTP service implementation. 因此,这取决于您的HTTP服务实现。

Connection pooling is also available if you don't want to deal with threads, as Mohammed wrote in his answer. 如Mohammed在他的回答中所写,如果您不想处理线程,则也可以使用连接池。

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. 对于Web服务,主要用法是通过cookie实现会话。 See this SO answer about authentication of a web service , for other possibilities. 有关其他可能性,请参阅有关Web服务认证的SO答案 IMHO a RESTful approach (ie stateless) is worth considering for a web service. 恕我直言,RESTful方法(即无状态)对于Web服务值得考虑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM