1

I'm hosting a CouchBase single node cluster in GCP and a flask backend OpenShift cluster which supports angular frontend. The problem is, when a post is called in my flask by my angular, it is taking too much time to get connected the VM (couchbase) and hence flask has to return a "504 Gateway Time-out". But this happens only sometimes. Sometimes it just works very well with proper speed. Not able to troubleshoot. The total data size is less than 100M, and everything is 100% memory resident in Couchbase. So I guess this is not a problem with Couchbase. Just the connection latency to GCP.

Jithin P Gopal
  • 138
  • 2
  • 10
  • 1
    You may be right. Since the issue is only happening randomly, I strongly suspects this also could be connected with resource component of the Google Cloud Platform node such a machine type. – Digil Jan 06 '20 at 19:52
  • 1
    As explained in the [best practice](https://resources.couchbase.com/cloud-partner-gcp/docs-deploy-gcp) article for deploying Couchbase on Google Cloud Platform, a machine with higher number of cores (typically > 16) will provide higher I/O limits/ performance than a machine with lower number of cores. It is worth to check this situation in your scenario. – Digil Jan 06 '20 at 19:53
  • Additionally, I found [this](https://developer.couchbase.com/documentation/server/3.x/admin/Misc/Trbl-timeoutErrors.html) troubleshooting article about various timeout errors as well. I would recommend you to read through it. It seems like they have explained some related scenarios/situations as that of yours over there. – Digil Jan 06 '20 at 19:57

2 Answers2

0

My guess is that the first time your flask backend is trying to connect for the first time to your VM, it's taking more than usual as it needs to establish the connection, authenticate and possibly do other things depending on your use-case.

This is a common problem when hosting your app on App Engine or something similar and the solution there is to use "warm-up requests". This basically spins up the whole connection (and in app engine case the instance) and makes a test connection just so when the desired connection comes, everything is already set up.

So I suggest that you check how warm-up requests work and configure something similar between your flask and VM. So basically a route in flask with the only purpose of establishing a test connections with a test package. This way your next connection will be up to speed with no 504 errors.

Waelmas
  • 1,894
  • 1
  • 9
  • 19
  • It is not always the first connection that gets delayed. Sometimes when I try 10 times, may be the its the last connection. or 5th. Anything. All random. – Jithin P Gopal Dec 31 '19 at 09:23
0

try to clear to cache of load balancer in GCP console

I already faced same kind of issue and resolved it using above technique

Amit Desale
  • 1,281
  • 3
  • 16
  • 43