简体   繁体   English

Cloud Foundry的服务到服务通信

[英]Service-to-service communication for Cloud Foundry

I need to deploy two node services to CF (each service in its own container). 我需要将两个节点服务部署到CF(每个服务都在其自己的容器中)。 The apps need to communicate. 应用程序需要通信。 How is it recommended to implement this communication? 建议如何实施这种沟通? I can't find any guide which explains service-to-service communication in CF, and since it should deploy to the cloud I need some best practices. 我找不到任何说明CF中服务到服务通信的指南,并且由于它应该部署到云中,因此我需要一些最佳实践。 Some examples will be very helpful. 一些示例将非常有帮助。

This is a classic question that always come to solve any enterprise application integration pattern and it comes down to the point that, what type of integration needs one has. 这是一个经典的问题,总是会解决任何企业应用程序集成模式,并且最终归结为需要什么样的集成类型。

If an app want to have synchronous communication to get a real time response, RESTFul APIs are the most loved integration style of this age. 如果应用程序希望通过同步通信来获得实时响应,则RESTFul API是该时代最受欢迎的集成风格。 But one also need to consider that, creation of huge numbers of APIs (which is the downside of going with Microservices based architecture) also brings-in the huge overhead of maintaining the set and locating the correct one. 但是,还需要考虑的是,创建大量的API(这是基于微服务的体系结构的缺点)也带来了维护集和定位正确集的巨大开销。 An API Gateway and a Service Discovery tools should be of help here. API网关和服务发现工具在这里应该有所帮助。 I am a novice about Blue-mix but you can surely host a Spring-Cloud-Eureka or Consul based Service Discovery on it to serve the purpose, and similarly Spring Cloud Zuul to have an API Gateway. 我是Blue-mix的新手,但是您可以肯定地在其上托管Spring-Cloud-Eureka或基于Consul的服务发现来实现此目的,并且类似地, Spring Cloud Zuul拥有一个API网关。

Another simple catch here is to ensure not to build one central service as fat spof to cater to whole of your microservices world but rather have many such services each catering to a contextually bound microservices. 这里的另一个简单问题是,确保不构建一个集中服务来迎合整个微服务世界,而是拥有许多此类服务来满足上下文绑定的微服务。

On the similar line, if the need is to have async communication , message brokers such as - RabbitMQ, Kakfa should be the best and simplest integration style for apps to communicate. 同样,如果需要进行异步通信 ,则消息代理(例如-RabbitMQ,Kakfa)应该是应用程序通信的最佳和最简单的集成方式。 The same catch of not building a SPOF service but rather have separate service instances one each for a set of bounded microservices applies here as well, with all these instances being further federated for wider communication should be taken care of. 同样的要点不是建立SPOF服务,而是有一组单独的服务实例,每个服务实例对应一组有界微服务,这在这里也适用,所有这些实例都应进一步联合以进行更广泛的通信。

Your answer will depend on what kind of communication you want between your apps. 您的答案将取决于您希望应用之间进行哪种通信。

If you're looking to deploy a microservice-based architecture pattern for your Node services, ie server code that performs an independent, granular business function, I would recommend getting started reading the docs here and using the new Bluemix Developer Console . 如果您希望为Node服务部署基于微服务的架构模式,即执行独立,精细的业务功能的服务器代码,那么我建议您开始在这里阅读文档并使用新的Bluemix Developer Console

Here there is a growing set of patterns and starters that you can use to understand and develop cloud native apps that can communicate to each other by exposing API endpoints compliant with the Open API specification and auto-generating SDKs for your omnichannel client applications. 这里有越来越多的模式和启动器,您可以用来了解和开发可通过彼此公开与Open API规范兼容的API端点并为全渠道客户端应用程序自动生成SDK来相互通信的云本机应用程序。

After downloading the selected starter, you can modify the code to expose an API that performs the business logic that you need. 下载选定的启动器后,您可以修改代码以公开执行所需业务逻辑的API。 Subsequently, you can run your project locally in a container or deploy it to Bluemix using the bx dev command line tool. 随后,您可以在容器中本地运行项目,或使用bx dev命令行工具将其部署到Bluemix。

After setting that up, you will have cross platform, language independent communication between your microservices and client applications. 设置好之后,您将在微服务和客户端应用程序之间进行跨平台,独立于语言的通信。

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

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