限制终端服务器下应用程序实例数量的技术
我正在寻找简单的方法来监视和限制终端服务器(2003 和 2008)下我们的应用程序实例的数量。
此限制的目的是确保我们的服务器不会超载。这是内部管理要求 - 我不是在寻找许可解决方案。
有问题的应用程序是用 Python 2.6(32 位)编写的,但我很高兴收到与开发工具无关的答案。虽然我们没有使用 Citrix,但我很高兴收到 Citrix 相关的想法,希望我可以在终端服务器上使用类似的技术。
I'm looking for simple ways to monitor and limit the number of instances of our application under Terminal Server (2003 and 2008).
The purpose of this restriction is to make sure we don't overload our servers. This is an internal administrative requirement - I am not looking for a licensing solution.
The application in question is written in Python 2.6 (32-bit) but I'm happy to receive development tool agnostic answers. Although we are not using Citrix, I am happy to receive Citrix related ideas with the hope that I can use a similar technique with Terminal Server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
应用程序的各个实例需要某种方式相互通信。当实例启动时,它会询问“有多少个实例已经在运行?”。如果超过允许的
n
,则选择不启动。一种实现方法可能是让
n
个文件锁定您允许同时运行的应用程序的n
个实例。然后,应用程序尝试锁定其中一个文件;如果不能,它会立即退出。完成后释放锁定,但如果您崩溃,操作系统可能会为您释放锁定。另一种方法是在启动时在中央位置(某个数据库)注册一些每个进程的唯一信息(PID?)。
第三种可能是使用仅主机网络服务器,其中专用服务器程序或实例之一协调与其他实例的通信。如果主机退出,其他实例之一可以自我提升为服务器。
The various instances of your application need some way to communicate with one another. When an instance starts up, it asks the question, 'how many are already running?'. If there are more than the allowed
n
, it chooses not to start up.One implementation approach might be to make
n
files to lock for then
instances of your application you allow to run at the same time. Then, the application tries to get a lock on one of those files; if it can't, it exits immediately. Release the lock when you're done, but presumably the OS would release the lock for you if you crash.Another approach would be to register some per-process unique piece of information (a PID?) in a central location (some database) when you start.
Yet a third might be to use a host-only network server where either a dedicated server program or one of the instances coordinates communications with the other instances. If the host exits, one of the other instances can self-promote to being the server.
根据 Python Win32 API 邮件列表的反馈,我还在考虑以下技术之一:
使用 Windows 信号量
使用互斥体池(提供比信号量更好的可恢复性)< /p>
使用一系列端口
Based on feedback on the Python Win32 API mailing list I'm also considering one of the following techniques:
Using Windows Semaphores
Using a pool of Mutexes (offer better recoverability than semaphores)
Using a range of ports