将应用程序迁移到服务模式 [java/groovy]
我有一个用 groovy 编写的应用程序。它需要一些 cmd 参数并返回先前格式化的响应。随着系统的增长,似乎需要极其频繁地运行该应用程序(例如 5 分钟内运行 80 次),这会导致某些性能问题。特别是,它一遍又一遍地创建所有对象,这导致一次运行最多填充 60MB RAM(可以轻松计算 ROM/交换的使用程度)。
我想将其迁移到服务运行模式,该模式将仅接受某些参数并返回格式化输出。但是:
- 应用程序总是由bat/sh脚本触发(这是无法更改的)
- 脚本和应用程序都在同一主机服务器上
所以,我想知道如何更好地执行脚本和应用程序的通信服务?
PS:抱歉,我没有提到,它是一个独立的应用程序,它永远不会使用服务器或类似的东西,因为它看起来是多余的。解决方案应该尽可能简单并且极其轻量。
示例:我现在能想到的最简单的事情就是永远不要迁移它(我知道这是矛盾的;))并简单地引入一个数据库,其中将存储所有结果,并且应用程序将有自己的触发时间安排。每当它被任何参数触发时,它应该简单地搜索数据库中的最新结果并返回它。简单、轻便、快速且有效。 :)
I've got an application written in groovy. It takes some cmd args and returns previously formatted response. As system grew, it appeared that it is required to run this app extremely frequently (like 80 times in 5 mins) which leads to certain performance issues. In particular it creates all its objects over and over again which leads to filling up to 60MB RAM in one run (can be easily calculated how severely ROM/swap is used).
I want to migrate it to a service running mode which will simply take certain params and return formatted output. But:
- App is always triggered by a bat/sh script (this can't be changed)
- Both script and app are on the same host server
So, I'm wondering how it would be better to perform the communication of a script and a service?
P.S.: Sorry that I didn't mention, it's a standalone app, it will never use a server or anything like that as it appears to be redundant. Solution should be as simple as possible and extremely lightweight.
Example: The simplest thing I can think of by now is never to migrate it (I know it's contradictory ;)) and simply introduce a DB where all thee result will be stored and an app will have it's own schedule of when to trigger. Whenever it is triggered with any params, it should simply search the latest result in DB and return it. Easy, light, fast, and working. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于企业环境,我建议在应用程序服务器中运行带有 EJB 的 JavaEE 应用程序。对于您的要求,这可能有点过分了。一个简单的解决方案可以是:
RMI 服务器
RMI 客户端
RMI 接口
For enterprise environments I would suggest a JavaEE application with EJB running in an application server. For your requirements this might be an overkill. A simple solution can be:
RMI Server
RMI Client
RMI Interface