Facing service unavailable error while implementing load balanced architecture #112
-
KV Version : 22.2.13 I am using Oracle NoSQL Database for one of the project. I have configured the proxy server and the communication between DB and Application is established.
I created 4 instances of proxy to enable load balanced architecture and also configured the HAproxy to distribute load to the four proxy servers.
When I am trying to make NoSQL client with nodeJS driver it is throwing an error message stating "Service Unavailable"(HTTP_RESPONSE_CODE 503).
Kindly help in this regard.
And also suggest if there is any other way to implement load balanced architecture in Oracle NoSQL Database (on-prem). |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 2 replies
-
I will review it tomorrow and provide you instructions to setup HA-proxy |
Beta Was this translation helpful? Give feedback.
-
Sure. It's non-secured NoSQL cluster |
Beta Was this translation helpful? Give feedback.
-
Node.js application connection return new NoSQLClient({
serviceType: ServiceType.KVSTORE,
endpoint: process.env.NOSQL_ENDPOINT + ":" + process.env.NOSQL_PORT
}); Deploy your cluster and start the HTTP proxy in the nodes. Note: The Oracle NoSQL Database Proxy can run in one or multiple dedicated hosts. It can be hosted inside the nodes of the NoSQL Cluster. e.g java -jar $KVHOME/lib/httpproxy.jar -helperHosts $KVHOST:5000 -storeName $KVSTORE -httpPort 8080 -verbose true Test using curl for all nodes hosting a HTTP proxy curl -v http://node1-nosql:8080 Test using your Oracle NoSQL SDK for Node.js example for all nodes hosting a HTTP proxy export NOSQL_ENDPOINT=node1-nosql
export NOSQL_PORT=8080
node test.js Configuring the Load BalancerYou can use a load balancer as frontend which has a backend set of multiple NoSQL proxies on different hosts. In this case, you can setup HA proxy. Install haproxy - in an external node to run the Load Balancer sudo yum install haproxy Add the following lines at the end of the file in my case,
Restart HA proxy and validate the status sudo systemctl stop haproxy.service
sudo systemctl start haproxy.service
sudo systemctl status haproxy.service
Test using curl curl -v http://nosql-lb:8080 Test using your Oracle NoSQL SDK for Node.js example export NOSQL_ENDPOINT=nosql-lb
export NOSQL_PORT=8080
node test.js TroubleshootingThe following error happens if:
NoSQLServiceError: [SERVICE_ERROR] Unsuccessful HTTP response. Status code: 503. Status message: Service Unavailable
at HttpClient._handleResponse (/home/opc/demo-graphql-nosql/blogloader/node_modules/oracle-nosqldb/lib/http_client.js:93:33)
at IncomingMessage.<anonymous> (/home/opc/demo-graphql-nosql/blogloader/node_modules/oracle-nosqldb/lib/http_client.js:150:22)
at IncomingMessage.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) Let me know if it works, Otherwise, please provide the output for the command documented here |
Beta Was this translation helpful? Give feedback.
-
Thanks @dario-vega for the detailed explanation. I tried the same on my environment. It's working till creating the client of DB.
But when I try to put some data in the table using the client facing the following error:
Error Msg:
The same code is working when I change the endpoint from load balancer host to proxy host. Please assist here.. |
Beta Was this translation helpful? Give feedback.
-
Provide the HA proxy version used.
Here is an extract of my configuration file
Please provide the output for the following commands (use your IPs and ports) for each line with the server directive.
You can also use DNS entries.
FYI, my test code is creating a table and inserting data, not just making a connection I am using
|
Beta Was this translation helpful? Give feedback.
-
I restarted the haproxy and proxy instances and now it's working properly. Thanks @dario-vega for your help.. |
Beta Was this translation helpful? Give feedback.
-
This is a really interesting question for our Q&A so I moved it to this repository as a GitHub Discussion. |
Beta Was this translation helpful? Give feedback.
Node.js application connection
Deploy your cluster and start the HTTP proxy in the nodes.
Note: The Oracle NoSQL Database Proxy can run in one or multiple dedicated hosts. It can be hosted inside the nodes of the NoSQL Cluster.
e.g
node1-nosql, node2-nosql, node3-nosql
in my case, I am using the port 8080.Test using curl for all nodes hosting a HTTP proxy
node1-nosql, node2-nosql, node3-nosql