How to Gracefully Prepare a Busy Backend Server for Maintenance

May 31, 2024 | 4 minute read
Atefeh (Ati) Yousefi-Attaei
Senior Cloud Engineer | North America Cloud Engineering
Text Size 100%:



The OCI Load Balancer service is a powerful tool that provides automated traffic distribution from one entry point to multiple backend servers reachable in an OCI Virtual Cloud Network (VCN). It can significantly improve application performance, decrease server load, and facilitate scaling with high flow availability. With advanced proxy features such as layer-7 routing, SSL termination, and End-to-End SSL Tunneling, it's a reliable choice for your infrastructure needs.

When you create an OCI Load Balancer, you must specify the backend servers to include in each backend set.

The load balancer routes incoming traffic to these backend servers based on the policies you specified for the backend set. You can use the Console, CLI, or API to edit backend servers in a backend set.

This blog will show you how to edit an LB backend server through the OCI Command Line Interface (CLI).

As a prerequisite, you must have proper knowledge of OCI, Load Balancer components, and the required IAM policy to manage the LB in OCI.

For more info, please check the reference link below.


Editing an LB in OCI via CLI involves using the command below.


“oci lb backend update --backend-name <backend_name> --backend-set-name <backend_set_name> --load-balancer-id <load_balancer_id> --backup [true|false] --drain [true|false] --offline [true|false] --weight weight [OPTIONS]”


Let’s start by gathering information about Load Balancer and its backend set.

Note: I already configured a Load balancer with two backend servers. For more information on how you can create an LB on OCI, please check this link out.


Log into the OCI portal and navigate to Networking > Load balancers> Load balancer details page.

Click on Load balancer OCID and copy it (Save it on a notepad. You need this later here).


Now, from the details page, click on Backend sets> Backend set details.

Copy your Backend set name (Save it on a notepad. You need this later here).


Now, click on the OCI Developer tools icon > Cloud Shell.


Run the command below and fill in the backend set name and Load balancer ID with yours, which was already saved in the previous steps above.

“oci lb backend-set get --backend-set-name < backend_set_name > --load-balancer-id < Load_balancer_id>”

As you can see below, running that command gives you a full view of your backend set server's IP address, weight, health check, LB policy, and more.


From the command's outcome, you can find your server backend name ( web server IP address followed by port number "Copy that and run the command below to get your work request ID.

“oci lb backend update --backend-name <backend_name> --offline true --weight 1 --backup false --drain true --backend-set-name <backend_set_name> --load-balancer-id <load_balancer_ocid>”

Note: Parameter indicates whether (true) or not (false). 

In my case, I set the "offline" and "drain" parameters to "true."

Understanding and correctly setting these parameters is key to effectively managing your backend servers.

Note: The drain parameter indicates the load balancer drains this backend server. If the value is true, the backend server receives no new incoming traffic.


Copy the service request and run the command below.

"oci lb work-request get --work-request-id < work_request_id>"

Note: Many CLI operations we use to create and configure compute resources take effect after some time. The operation spawns an asynchronous workflow to fulfill the request in these cases. Work requests provide visibility into the status of these in-progress, long-running workflows.


Note: We have four work request states: Accepted, In Progress, Succeeded, and Failed.

As you see in the screenshot above, it shows “Succeeded,” which means a work request record exists for this request, and an associated WORK_COMPLETED record has the state Succeeded.

Let’s check the Load balancer backends from the OCI dashboard. As you see below, my server drain status changed to “Drained,” and the server was turned off. As a result, that backend server has a critical health status.



Using the Oracle Cloud Infrastructure CLI commands to edit the Load balancer configuration is a powerful and efficient way to manage your LB resources. Mastering these CLI commands can significantly enhance your infrastructure management capabilities within the OCI environment.


I hope you enjoyed it!

Atefeh (Ati) Yousefi-Attaei

Senior Cloud Engineer | North America Cloud Engineering

Previous Post

Generative AI for Natural Language Processing

Mani Krishnan | 14 min read

Next Post

Identity Domain API invocation using signed requests via Postman

Manasi Vaishampayan | 2 min read