当REST客户端和服务器位于同一台服务器上时,如何避免网络调用 [英] How to avoid network call when REST client and server are on the same server

查看:124
本文介绍了当REST客户端和服务器位于同一台服务器上时,如何避免网络调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,其中两个主要组件是网站(在Groovy和Grails中实现)和后端RESTful Web服务(使用JAX-RS(Jersey)和Spring实现)。这两个都将在Glassfish中运行。该网站将调用RESTful Web服务。在很多情况下,这些组件将驻留在不同的服务器上,因此网站将通过网络拨打RESTful Web服务。但是,如果我在同一个Glassfish服务器上运行这两个应用程序,是否可以进行优化以避免网络调用?换句话说,我正在寻找一些等价的用于REST的EJB远程/本地接口。谢谢!

I have a web application in which two of the major components are the website (implemented in Groovy and Grails) and a backend RESTful web service (implemented using JAX-RS (Jersey) and Spring). Both of these will be running in Glassfish. The website will make calls to the RESTful web service. In many cases, these components will reside on separate servers, so the website will make calls over the network to the RESTful web service. If, however, I run both applications in the same Glassfish server, are there any optimizations that can be made to avoid the network call? In other words, I'm looking for some equivalent of EJB's remote/local interfaces for REST. Thanks!

推荐答案

不要冒着网络电话。您的流量通常不会离开本地界面,因此您不会占用任何带宽。你从序列化/反序列化中失去了一点性能,但是你需要问自己是否值得开发一个复杂的代理体系结构来减少这种影响。我想大多数情况下你会发现答案是否定的。

Don't sweat the network call. Your traffic will generally never leave the local interface so you won't be consuming any bandwidth. You lose a bit of performance from serialization/deserialization, but you'll need to ask yourself if reducing the impact of this is worth developing a complicated proxy architecture. I think it most cases you'll find the answer to be no.

这篇关于当REST客户端和服务器位于同一台服务器上时,如何避免网络调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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