I am running a node.js app on Bluemix which basically is a REST API for read/write operations on a Cloudant (CouchDb) database. Incoming requests are authenticated by an injected passport-http-bearer strategy middleware into the express framework. My app uses the bearer token to receive information about the user.
This is not very performant at the moment (we are working on a caching mechanism), but in general it works. When I send much requests in parallel (e.g. in function tests), sometimes I receive the 502 Bad Gateway response instead of the expected results, which fails nearly every test suite run. On my local deployment it works without problems.
答案 0 :(得分:2)
@ Jeff-Sloyer在推送脚本中建议重试逻辑是正确的。此外,您应该检查运行时的状态以及Bluemix状态页面上使用的任何服务。有关您可能收到此错误的原因的详细信息,请参阅以下信息:
https://www.ng.bluemix.net/docs/troubleshoot/managingapps.html
答案 1 :(得分:2)
也许您有缩放问题?当你说很多并行请求时 - 服务回复时间是否可能超出路由器预期的时间(我认为120秒)并且有很多请求?
你可以尝试使用Apache Bench更加努力地推动你的应用吗?
ab -n 10000 -c 100 -s 120 -H "Authorization: Bearer <token>" https://your-app/
然后并行检查响应,例如:
#!/bin/bash
BEARER=<your-token>
URL=<your-app>
TIMEFORMAT="TIME: %E"
while true; do R=$(time echo -e REQUEST: $(date)\\nREPLY: $(curl -X GET -s --insecure --header "Accept: application/json" --header "Authorization: Bearer $BEARER" "https://$URL") 2>>trace); echo "$R" >>trace; echo $R|grep -q "502" && echo -e "Found 502 reply\n$R"; done
HP
答案 2 :(得分:0)
I have seen this with unreliable networking. I would use some retry login for your push script to guarantee a deploy.