需要为应用程序服务器 - Java的 [英] Need for an application Server - Java

查看:173
本文介绍了需要为应用程序服务器 - Java的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自一个客户端编程背景(C ++大部分)。不过,我现在偶尔需要进入Java中与放一些小的服务器端项目;因此,需要有经验的服务器端的人一些建议。我真的不明白很多关于应用程序服务器。

I come from a client side programming background (C++ mostly). However, I now have the occasional need to get into some small server side projects in Java & hence need some advice from experienced server side people. I don't really understand much about Application servers.

是否有拇指规则和注意事项,当一个程序需要的应用服务器(比如GlassFish或JBoss的)?

Are there any thumb rules or considerations to decide when a program needs an application server (like GlassFish or JBoss)?

我用Java编写的专用机都运行2台服务器。一台服务器上运行Tomcat没有任何应用服务器。第二个服务器的应用程序服务器(Glassfish的)上运行。

I have 2 servers written in Java both running on dedicated machines. One server runs on Tomcat without any App Server. The second server runs on an application server(Glassfish).

我需要写一个相当简单的程序,它坐落在中间。这是该方案将做

I need to write a rather simple program which sits in the middle. This is what the program will do


  • 监听套接字。当连接来自第一台服务器,它创建一个线程来接受连接和放大器;继续监听。

  • listen on a socket. When a connection comes from the first server, it creates a thread to accept the connection & continue listening.

该线程会从第一台服务器的数据量小(比如100-200个字节),数据是否与放大器的非常少量格式;将其传递到通过Web服务调用的第二个服务器。它需要返回Web服务调用的价值,并在此基础上做一些处理 - 可能是在10-20 code线 - 这是不是有些主要加工 - 不同的(3)服务器上只有几个web服务调用。在此之后,它返回一些数据返回给第一服务器 - 再次不多 - 可以是50字节

the thread gets a small amount of data (say 100-200 bytes) from the first server, does very minor formatting of the data & passes it on to the second server through a webservice call. It takes return value of the webservice call, and based on it does some processing - may be around 10-20 lines of code - this is not some major processing - just a few webservice calls on a different (3rd) server. After this, it returns some data back to the first server - again not much - may be 50 bytes.

我的程序是不是一个web服务。它只是在一个特定的格式和放大器的第一台服务器获取信息;使一个web服务调用来基于从所述第一服务器接收到的数据中的第2个服务器。在someways你可以用这种方式把它 - 它作为第一个服务器做一个Web服务调用到第二个服务器的代理。

My program is not a webservice. It just gets messages from the first server in a particular format & makes a webservice call to the 2nd server based on the data received from the first server. In someways you can think of it in this way - it acts as a proxy for the first server to make a webservice call into the 2nd server.

所有的主要工作是通过Tomcat服务器和放大器上运行的应用程序运行的第一台服务器完成的; Web服务在GlassFish运行。这些都被很好的测试程序。中间的程序我想写为pretty简单&放大器;我能得到它在半天完成。不过,我担心的是,如果它就能带负载。

All the major work is done by the first server running by the app running on the Tomcat Server & the Web Services running on GlassFish. These both are well tested programs. The middle program I want to write is pretty simple & I can get it done in half day. However, what I am worried about is if it will be able to take the load.

什么样的​​规则/考虑在那里弄清楚,如果我可以只运行这个Java程序作为普通Windows服务或做我需要像Glassfish的或任何其他应用程序服务器。

What kind of rules/considerations are there to figure out if I can just run this Java program as a regular windows service or do I need something like Glassfish or any other Application Server.

我应该考虑在每分钟/小时到来的连接数?我会派生一个线程为每个连接,但线程本身不会很长住。在什么门槛连接数的我应该考虑应用程序服务器?是否还有其他的考虑?我会强烈preFER避免应用服务器,如果可能的话。

Should I consider the number of connections coming in per minute/hour? I will be forking a thread for each connection but the thread itself would not be very long lived. At what threshold of number of connections should I consider an Application Server? Are there any other considerations? I would highly prefer to avoid an Application Server, if possible.

无论到应用程序服务器下运行,这只是一个问题 - ?有没有任何问题,我在这里失踪

Whether to run it under an App Server is just one question - are there any more questions I am missing here?

推荐答案

应用程序服务器是不是不可思议,因为他们不创造更好的性能。事实上,如你提出了一个简单的应用程序,应用程序服务器很可能会因为所有的额外的开销大多数应用服务器引入了相反的效果。

Application servers are not magical, in that they do not create better performance. In fact, for a simple application such as you've outlined, an application server would likely have the opposite effect because of all the extra overhead most application servers introduce.

应用程序服务器提供了基础架构组件,务实为模式的企业级开发,以及标准规范实现。他们组织较大规模的开发力度,调整设定了规模较大的相对短暂的连接数量主要是有用的。这就是说,重量轻的服务器,如Tomcat或Jetty可以,如果你已经熟悉他们所提供的基础设施中使用。特别是,他们会为你提供入站HTTP连接处理。

Application servers provide infrastructure components, pragmatic patterns for enterprise level development, and implementations of standards specifications. They are primarily useful for organizing larger scale development efforts and setting things up to scale for larger numbers of relatively short-lived connections. That said, light weight servers such as Tomcat or Jetty can be used if you are already familiar with the infrastructure that they provide. In particular, they would provide inbound HTTP connection handling for you.

我想根据您的问题说明,虽然,你会过得更好用写如阿帕奇HttpComponents <库一个独立的Java服务/ A>来处理HTTP和WebService客户端功能。目前尚不清楚你需要多少额外的工作来处理入站连接。如果简单的插座,那么它很容易这个程序自己。

I think based on your problem description though, you would be better off writing a standalone java service using libraries like Apache HttpComponents to handle the HTTP and WebService client functionality. It's not clear how much extra work you need to handle inbound connections. If simple sockets, then it's very easy to program this yourself.

您对您需要多少个连接同时支持的描述是模糊的(它是相对的)。如果你需要每个连接一个线程,并期望支持数以百计的连接,那么我建议你实现连接与线程的连接池处理,确保新的连接,耗尽服务器的能力之前阻塞。如果去这条路线,检查出的Java 5+ ExecutorService的和相关类。

Your description regarding how many connections you will need to support simultaneously is vague (and it's all relative). If you need one thread per connection and expect to support hundreds of connections, then I would suggest implementing your connection handling with a thread connection pool, making sure that new connections block before exhausting your server's capabilities. If going that route, check out the Java 5+ ExecutorService and related classes.

我怀疑应用程序服务器将提供多少好处,如果你的需求很简单。

I doubt an Application server will provide much benefit if your needs are simple.

这篇关于需要为应用程序服务器 - Java的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆