简体   繁体   English

我可以在同一个项目中使用JRuby on Rails和Java Servlet吗?

[英]Can I use JRuby on Rails and Java Servlet in a same project?

My project requires both Rails and Java for special scaling ability. 我的项目需要Rails和Java才能实现特殊的扩展能力。

We firstly started a pure JRuby on Rails project, and deploy it to Tomcat. 我们首先启动了一个纯粹的JRuby on Rails项目,并将其部署到Tomcat。 The problem is our Tomcat server has a very limited resource with only 20-30 threads. 问题是我们的Tomcat服务器资源非常有限,只有20-30个线程。 It means that our web app can only concurrently serve 20-30 users at a time. 这意味着我们的网络应用程序一次只能同时为20-30个用户提供服务。

We plan to improve the throughput by converting some heavy synchronous code to evented-code by using EventMachine. 我们计划通过使用EventMachine将一些繁重的同步代码转换为偶数代码来提高吞吐量。 With evented-code a single thread can do more work instead of waiting for a long-time job to finish. 使用事件代码,单个线程可以完成更多工作,而不是等待长时间工作完成。

But to use EventMachine, the web server must be event-based, while Tomcat is not the case. 但是要使用EventMachine,Web服务器必须基于事件,而Tomcat则不是这样。

It seems there is no hybrid multi-threaded and evented solution in JRuby/Tomcat, so we decide to combine the asynchronous support in Servlet 3.0 with our current Rails app. 似乎在JRuby / Tomcat中没有混合多线程和事件解决方案,所以我们决定将Servlet 3.0中的异步支持与我们当前的Rails应用程序结合起来。 Some parts of the code will be written in Java with Servlet library. 代码的某些部分将使用Servlet库用Java编写。 It sounds crazy, but we think it's the most suitable for us. 这听起来很疯狂,但我们认为它最适合我们。

Is there anyway I can do that with JRuby Rails, Warbler and Java Servlet 3.0 ? 无论如何我可以用JRuby Rails,Warbler和Java Servlet 3.0做到这一点吗?

Thanks for all your interest. 感谢您的所有兴趣。 Any suggestion is very appreciated. 任何建议都非常感谢。

I haven't tried this myself, but I guess you should be able to create a standard jruby+rails app, package it as a war file and then configure web.xml to use servlets on some url's. 我自己没有尝试过,但我想你应该能够创建一个标准的jruby + rails应用程序,将其打包为war文件,然后配置web.xml以在某些url上使用servlet。

Besides, this benchmark indicates a hybrid java and jruby solution is a great idea to optimize bottlenecks http://www.techempower.com/blog/2013/03/28/framework-benchmarks/ 此外,这个基准测试表明混合java和jruby解决方案是优化瓶颈的好主意http://www.techempower.com/blog/2013/03/28/framework-benchmarks/

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

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