Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 express 构建一个微服务,并且需要对每个请求进行一些操作(比如日志记录)。我发现 sidecar 对此很有用,但是使用 express 中间件可以实现相同的功能。是否有任何场景建议使用边车而不是使用中间件?
使用 sidecar 的一个主要优点是您可以将业务逻辑代码与日志记录代码(通常是第 3 方库)分离。这是一个优势,因为如果第 3 方插入导致代码崩溃的错误,它不会影响代码的执行(除了不记录)。
缺点是 Sidecar 与任何额外的外部进程一样,需要 CPU、内存、磁盘等资源开销。