简体   繁体   English

微服务应如何在Docker中彼此通信

[英]how should microservices talk to each other in docker

I have a Rails app which I moved to docker. 我有一个移至docker的Rails应用程序。 The process forced me to split the app into 2 microservices: the main app and an address verification microservice. 该过程迫使我将应用程序分为2个微服务:主应用程序和地址验证微服务。 I encapsulated the address verification microservice into another Rails app which my main app calls. 我将地址验证微服务封装到另一个主应用程序调用的Rails应用程序中。 It uses rest-client and it blocks until it receives a response. 它使用rest-client并阻塞直到收到响应。

Requests used to be processed in 300ms. 过去需要300毫秒来处理请求。 Now, they take 1.3s. 现在,他们需要1.3秒。 After looking at the newrelic data, it seems the bulk of the time is spent in the main Rails app calling the address verification Rails app. 在查看了newrelic数据之后,似乎大部分时间都花在了主Rails应用中,用于调用地址验证Rails应用。 Is there a way microservices should communicate between containers? 微服务有没有办法在容器之间通信? I guess my question is Ruby/Rails specific. 我想我的问题是特定于Ruby / Rails的。 Should I look into RabbitMQ? 我应该研究RabbitMQ吗? The problem is that I need a verified address very early into the flow, so I'm not sure how much time an asynchronous request to the address verification microservice Rails app will buy me. 问题在于,我需要在流程的早期就获得一个经过验证的地址,因此我不确定向地址验证微服务Rails应用发送异步请求会花多少时间。

新数据

It turns out that the address verification microservice had a problem. 事实证明,地址验证微服务有问题。 I had enabled devise on the address verification and the user find/update actions were taking a lot of time. 我已经启用了地址验证方面的设计,并且用户查找/更新操作花费了大量时间。 I'm still not sure why they were taking so long, but soon as I disabled them, I went back to decent numbers. 我仍然不确定为什么要花这么长时间,但是一旦我禁用了它们,我就回到了不错的数字。 I'll need to find out what the hell was happening with devise. 我需要找出设计到底发生了什么。 It's still not what I had with internal calls, but docker & microservices is not that terrible. 内部调用仍然不是我想要的,但是docker&microservices并不那么糟糕。

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

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