What is Network Load Balancer (NLB)?
Network Load Balancer works in Layer 4 and is best fit for business-critical and interactive workloads that require high throughput and low latency.
-- from IBM Cloud blog
With traditional load balancer, all incoming and returning traffics would go through the load balancer itself. The big disadvantage is the high volume of traffics will increase the latency and affect the throughput.
NLB is using a technology called Direct Server Return (DSR). The information processed by the backend targets is sent directly back to the client, thus minimizing latency and optimizing throughput performance.
-- from IBM Cloud blog
Node.js SDK
This Node.js SDK is a new tool for developer to manage their IBM Cloud VPC resources. If you are new to Node.js and need to use the Node.js SDK to manage your ALB/NLB on IBM Cloud VPC, this doc can help you to get start.
Import the VPC libaries:
Create VPC service object and authenticate:
Define some variables and sleep function that will be used below:
Define an async checkLbActive function:
List load balancers:
CREATE Load Balancer:
CREATE Load Balancer Listener:
CREATE Load Balancer Pool:
CREATE Load Balancer Pool Member:
UPDATE Load Balancer Listener:
UPDATE Load Balancer Pool:
UPDATE Load Balancer Member:
DELETE Load Balancer:
DELETE Load Balancer Listener:
DELETE Load Balancer Pool:
DELETE Load Balancer Pool Member:
Putting all the functions together and run it:
Github Repo that has all the code above: gugucode/ibm-vpc-nlb-nodejs-test
Some references:
Node.js SDK Github repo: https://github.com/IBM/vpc-node-sdk#using-the-sdk/