How to track session across several web apps, multiple microservices

梦想的初衷 提交于 2019-12-11 04:13:02

问题


I would like to track a session across multiple web applications, multiple microservices. All of my web applications are static files and microservices are running under nodejs containers with Kubernetes.

I have tracking setup across separate web applications and separate microservices. But it too cumbersome to merge and view everything in a single view.

Is there any approach to view all of them under single session?


回答1:


Kubernetes itself do not support any request tracing, but you can use Istio together with Kubernetes, which has Distributed Tracing feature.

In short, your application will need to resend attached headers and Istio will detects it, collect information from all your services and show you requests tracing.

Also, it supports Mesh, so, theoretically, your application can work a bit faster and secure (because of network rules).

You can read about Istio here, about tracing here and here is an instruction of how to setup it in Kubernetes.




回答2:


You can trace HTTP requests across different microservices (apps) using a special header to correlate all subsequent requests to the original one.

For example, your web app sends a HTTP request (REST API call) to the first microservice (A) which finds that the request does not have a correlation ID (x-correlationid header) and adds it, then saves that correrlation id into the current call/session context and forwards it to all subsequent API calls to other microservices. then when all other microservices are following the same logic they will also add/use the correlation ID, you will have the ability to trace a request throughout all the microservices in the system.

this pattern is used by many APM (application performance monitoring) tools. and once all your logs are aggregated in one place, you can then filter your queries by a certain correlation ID to see the full trace of a specific user request/operation.



来源:https://stackoverflow.com/questions/54274211/how-to-track-session-across-several-web-apps-multiple-microservices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!