Briefly, I need to create a server whose back end queries information from another server. I'm wondering how others might approach this problem.
简而言之,我需要创建一个服务器,其后端从另一个服务器查询信息。我想知道其他人如何解决这个问题。
Here's a longer description of the problem: I need to create a server (call this server Alpha) that makes requests to another server (call this server Omega) based on web pages that are requested by the client. The requests are network messages and are not SQL queries. The requested information will be part of the content that gets served to Alpha's clients. For example, the client might want to display a buddy list. Alpha would query Omega for the client's buddy list. Alpha then displays a web page with the buddy list.
以下是对问题的更长描述:我需要创建一个服务器(称为此服务器Alpha),该服务器根据客户端请求的网页向另一台服务器(称为服务器Omega)发出请求。请求是网络消息,不是SQL查询。请求的信息将成为提供给Alpha客户的内容的一部分。例如,客户端可能想要显示好友列表。 Alpha会向Omega查询客户的好友列表。然后Alpha显示一个包含好友列表的网页。
The clients cannot connect directly to Omega. The server Alpha pretty much just handles client connections, manages queries from the client to the Omega server and serves new web pages (which could contain information queried from Omega).
客户无法直接连接到Omega。服务器Alpha几乎只处理客户端连接,管理从客户端到Omega服务器的查询,并提供新的网页(可能包含从Omega查询的信息)。
I'm new to web development. I don't know much about Apache modules. But, it seems like most of the functionality is already available within Apache. It seems like Apache could be extended for sending the network messages that query information from the other server, Omega. Another option is to create the Alpha server from scratch.
我是网络开发的新手。我对Apache模块知之甚少。但是,似乎大多数功能已经在Apache中可用。看起来Apache可以扩展用于发送查询来自其他服务器Omega的信息的网络消息。另一种选择是从头开始创建Alpha服务器。
Which approach would you use? Is there another approach that is better?
你会用哪种方法?还有另一种方法更好吗?
3 个解决方案
#1
Without having more detail about what you're doing, it sounds like either of these approaches would be overkill. If I were doing buddy list querying in a modern Web programming environment, I would consider something like the following:
如果没有关于你正在做什么的更多细节,听起来这些方法中的任何一种都是过度的。如果我在现代Web编程环境中进行好友列表查询,我会考虑以下内容:
- Server Alpha is my normal Web stack: Apache, my app server (i.e. Passenger for Rails, or something like JBoss for Java, etc.).
- Server Omega is apparently already existing, so I won't address it. If it's not existing, it could be another server configured like Alpha.
Server Alpha是我的普通Web堆栈:Apache,我的应用服务器(即Passenger for Rails,或类似JBoss for Java等)。
服务器Omega显然已经存在,所以我不会解决它。如果它不存在,它可能是另一个配置为Alpha的服务器。
Given that:
- Web requests from users come to Alpha via the www.
- My Web app on Alpha connects to Omega via the appropriate protocol. This might be XMPP to query a Jabber server, or LDAP, or whatever. Omega returns its results.
- Web app on Alpha uses these results to build a page to return to the user.
来自用户的Web请求通过www进入Alpha。
我在Alpha上的Web应用程序通过适当的协议连接到Omega。这可能是XMPP来查询Jabber服务器,或LDAP,或其他什么。 Omega返回结果。
Alpha上的Web应用程序使用这些结果构建一个页面以返回给用户。
#2
Sounds like you want either a reverse proxy, or application server. You're a bit vague about what kind of data Omega is actually returning -- if you want Omega to generate web pages, then look into reverse proxies. Apache has a built-in proxy module, but I've heard that Squid has better performance:
听起来你想要一个反向代理或应用服务器。你对Omega实际返回的数据类型有点模糊 - 如果你想要Omega生成网页,那么请查看反向代理。 Apache有一个内置的代理模块,但我听说Squid有更好的性能:
- http://www.visolve.com/squid/whitepapers/reverseproxy.php
- http://wiki.squid-cache.org/SquidFaq/ReverseProxy
If Alpha and Omega are using a custom protocol, then you'll want to treat Omega as an application server.
如果Alpha和Omega使用自定义协议,那么您将要将Omega视为应用程序服务器。
#3
From the sound of it, it's the kind of system that would be served by a fairly ordinary scripted webpage. Using, for example, PHP the script calls the back-end web-service and produces a webpage with the information. How much processing is required, depends on the difference between the output from Omega and what you want the HTML to look like.
从它的声音来看,它是一种由相当普通的脚本网页提供服务的系统。例如,使用PHP脚本调用后端Web服务并生成包含该信息的网页。需要多少处理,取决于Omega的输出与您希望HTML的外观之间的差异。
An Apache module seems to be overcomplicated - and a whole new server complete overkill.
一个Apache模块似乎过于复杂 - 一个全新的服务器完全矫枉过正。
#1
Without having more detail about what you're doing, it sounds like either of these approaches would be overkill. If I were doing buddy list querying in a modern Web programming environment, I would consider something like the following:
如果没有关于你正在做什么的更多细节,听起来这些方法中的任何一种都是过度的。如果我在现代Web编程环境中进行好友列表查询,我会考虑以下内容:
- Server Alpha is my normal Web stack: Apache, my app server (i.e. Passenger for Rails, or something like JBoss for Java, etc.).
- Server Omega is apparently already existing, so I won't address it. If it's not existing, it could be another server configured like Alpha.
Server Alpha是我的普通Web堆栈:Apache,我的应用服务器(即Passenger for Rails,或类似JBoss for Java等)。
服务器Omega显然已经存在,所以我不会解决它。如果它不存在,它可能是另一个配置为Alpha的服务器。
Given that:
- Web requests from users come to Alpha via the www.
- My Web app on Alpha connects to Omega via the appropriate protocol. This might be XMPP to query a Jabber server, or LDAP, or whatever. Omega returns its results.
- Web app on Alpha uses these results to build a page to return to the user.
来自用户的Web请求通过www进入Alpha。
我在Alpha上的Web应用程序通过适当的协议连接到Omega。这可能是XMPP来查询Jabber服务器,或LDAP,或其他什么。 Omega返回结果。
Alpha上的Web应用程序使用这些结果构建一个页面以返回给用户。
#2
Sounds like you want either a reverse proxy, or application server. You're a bit vague about what kind of data Omega is actually returning -- if you want Omega to generate web pages, then look into reverse proxies. Apache has a built-in proxy module, but I've heard that Squid has better performance:
听起来你想要一个反向代理或应用服务器。你对Omega实际返回的数据类型有点模糊 - 如果你想要Omega生成网页,那么请查看反向代理。 Apache有一个内置的代理模块,但我听说Squid有更好的性能:
- http://www.visolve.com/squid/whitepapers/reverseproxy.php
- http://wiki.squid-cache.org/SquidFaq/ReverseProxy
If Alpha and Omega are using a custom protocol, then you'll want to treat Omega as an application server.
如果Alpha和Omega使用自定义协议,那么您将要将Omega视为应用程序服务器。
#3
From the sound of it, it's the kind of system that would be served by a fairly ordinary scripted webpage. Using, for example, PHP the script calls the back-end web-service and produces a webpage with the information. How much processing is required, depends on the difference between the output from Omega and what you want the HTML to look like.
从它的声音来看,它是一种由相当普通的脚本网页提供服务的系统。例如,使用PHP脚本调用后端Web服务并生成包含该信息的网页。需要多少处理,取决于Omega的输出与您希望HTML的外观之间的差异。
An Apache module seems to be overcomplicated - and a whole new server complete overkill.
一个Apache模块似乎过于复杂 - 一个全新的服务器完全矫枉过正。