最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Identifying in a load balancer - Stack Overflow

programmeradmin2浏览0评论

Based on:

/@vinodkrane/microservices-scaling-and-load-balancing-using-docker-compose-78bf8dc04da9

it is possible to have 2 or more copies of a docker compose service. My "original" service (named nodeserver) runs a node server running the next script:

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!');
  console.log(req);
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

The question is: If I use

docker compose up --scale nodeserver=3

how could I modify my script to find out if it is running "orchestrated" by a load balancer and the respective mirror it is working from?

发布评论

评论列表(0)

  1. 暂无评论