Oracle APEX Load Balancing: Step-by-Step Guide with ORDS, Nginx and High Availability
How to load balance Oracle APEX step by step: architecture, installing two ORDS nodes, sharing configuration and APEX images, Nginx load balancer with SSL, health checks, HTTPS header settings, database high availability, testing failover and common mistakes.
Oracle APEX · ORDS · High availability
Oracle APEX Load Balancing: Step-by-Step Guide with ORDS, Nginx and High Availability
An Oracle APEX application that starts with ten users often ends up with five hundred: a factory ERP, a hospital system or a public portal. At that point one ORDS server becomes both a performance limit and a single point of failure – if it stops, nobody can work. Load balancing APEX solves both problems. This guide walks through the complete setup, from planning to failover testing, with configuration you can adapt for Oracle Linux, RHEL or Windows Server and for on-premises or cloud (OCI, AWS, Azure) deployments.
1. How Oracle APEX handles requests (why load balancing is straightforward)
Oracle APEX itself runs inside the Oracle Database. The web tier is ORDS, a Java application that receives browser requests and passes them to the database through a JDBC connection pool. Three facts make APEX easy to scale horizontally:
- Session state lives in the database, not in ORDS memory. Any ORDS node can serve any request for any session.
- ORDS nodes are stateless apart from their configuration and connection pool, so you can add or remove nodes freely.
- Static files (the APEX
/i/images, JavaScript and CSS) are identical on every node, or can come from a CDN.
This means sticky sessions are not required for APEX. You can enable them on the load balancer if you like (some teams find it simpler for log reading), but the application does not depend on them.
2. Target architecture
SSL termination · health checks
app1:8080
app2:8080
RAC, Data Guard or single instance
| Layer | Purpose | Typical choice |
|---|---|---|
| Load balancer | Spreads requests, terminates SSL, removes failed nodes | Nginx or HAProxy on Linux; OCI/AWS/Azure load balancer in the cloud; F5 in large enterprises |
| ORDS nodes | Run APEX requests and REST APIs | 2+ servers (VMs or containers), same ORDS version and config |
| Database | Stores APEX, data and session state | Oracle 19c/23ai; RAC or Data Guard for database high availability |
3. Step 1 – Plan before you install
- Versions: every ORDS node must run the same ORDS version, and the APEX images (
/i/) must match the APEX version installed in the database. - Hostnames and ports: e.g.
app1.local:8080,app2.local:8080, public nameapex.yourcompany.com. - Certificates: a TLS certificate for the public name, installed on the load balancer.
- Connection pool size: decide the maximum JDBC connections per node, and make sure the database
processes/sessionslimits allow (nodes × max pool) plus your other connections. - Firewall: users reach only the load balancer on 443; ORDS ports are open only to the load balancer; the database listener (1521) only to ORDS nodes and admins.
4. Step 2 – Install and configure ORDS on the first node
Install Java (a supported JDK version for your ORDS release) and ORDS, then run the installer against your database. If you are starting from scratch, our guide to installing Oracle 19c, APEX, ORDS and JasperReports covers the database and APEX side.
# Linux example – adjust paths to your environment
mkdir -p /etc/ords/config
ords --config /etc/ords/config install # interactive: DB host, port, service name, passwords
# check the pool settings that were written
ords --config /etc/ords/config config list
Connect ORDS to a database service name, not a SID, and if you use RAC, to the SCAN address. That way the database can move the service between instances without changing ORDS.
Set the connection pool to suit your load (values here are a starting point, not a rule):
ords --config /etc/ords/config config set jdbc.InitialLimit 10
ords --config /etc/ords/config config set jdbc.MinLimit 10
ords --config /etc/ords/config config set jdbc.MaxLimit 60
5. Step 3 – Tell ORDS it is behind an HTTPS load balancer
The load balancer receives HTTPS and forwards plain HTTP to ORDS. Without extra configuration ORDS thinks requests are insecure, and you may see redirect loops, mixed-content warnings or “403 Forbidden” errors on login and form submissions. Configure the load balancer to send X-Forwarded-Proto: https and tell ORDS to trust it:
ords --config /etc/ords/config config set security.httpsHeaderCheck "X-Forwarded-Proto: https"
Also make sure the load balancer passes the original Host header, so URLs that APEX generates use the public name apex.yourcompany.com and not the internal node name.
6. Step 4 – Serve the APEX images on every node
Copy the images folder from the APEX installation zip (the version installed in your database) to the same path on each node, for example /opt/apex/images, and start ORDS with it:
ords --config /etc/ords/config serve --port 8080 --apex-images /opt/apex/images
Alternatively, point APEX to Oracle’s CDN for static files (Instance Administration → Instance Settings → image prefix), which removes the need to copy images and speeds up first page loads. Whichever you choose, every node must serve the same version.
Run ORDS as a service (systemd on Linux, a Windows service on Windows Server, or a container) so it restarts automatically after a reboot.
7. Step 5 – Add the second (and third) ORDS node
- Install the same Java and ORDS versions on the new server.
- Copy the whole ORDS configuration directory (
/etc/ords/config) from node 1. It contains the pool settings and the stored credentials, so protect it like a password file. - Copy the APEX images to the same path.
- Start ORDS on the same port and test it directly:
http://app2.local:8080/ords/should open the APEX login.
Keeping configuration identical is the single most important rule. A node with a different pool size, image path or HTTPS setting causes “random” errors that only some users see – the hardest kind of fault to diagnose.
8. Step 6 – Configure the load balancer (Nginx example)
Here is a working Nginx configuration for two ORDS nodes with SSL termination. HAProxy, F5 and cloud load balancers use the same ideas: a backend pool, a health check, and forwarded headers.
upstream ords_pool {
least_conn; # send new requests to the least busy node
server app1.local:8080 max_fails=3 fail_timeout=30s;
server app2.local:8080 max_fails=3 fail_timeout=30s;
keepalive 32;
}
server {
listen 80;
server_name apex.yourcompany.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name apex.yourcompany.com;
ssl_certificate /etc/nginx/ssl/apex.crt;
ssl_certificate_key /etc/nginx/ssl/apex.key;
client_max_body_size 50m; # allow file uploads in APEX
proxy_read_timeout 300s; # long reports and processes
location / {
proxy_pass http://ords_pool;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
}
Notes on this configuration:
least_connbalances better than simple round robin when some APEX pages (reports, exports) take longer than others.max_failsandfail_timeoutgive passive health checking in open-source Nginx: a node that keeps failing is taken out for 30 seconds. Commercial load balancers and HAProxy add active health checks (see the next step).client_max_body_sizemust be large enough for file browse items, or uploads fail with “413 Request Entity Too Large”.proxy_read_timeoutmust be longer than your slowest legitimate request, otherwise users see 504 errors on big reports.
9. Step 7 – Add a proper health check
A health check should prove that ORDS and the database connection work, not just that port 8080 is open. A simple way is a tiny ORDS REST endpoint that runs a query:
BEGIN
ORDS.ENABLE_SCHEMA(p_schema => 'HEALTH_API'); -- run as a small, low-privilege schema
ORDS.DEFINE_SERVICE(
p_module_name => 'health',
p_base_path => 'health/',
p_pattern => 'ping',
p_source => 'SELECT ''OK'' AS status FROM dual');
COMMIT;
END;
/
Point the load balancer’s health check at that URL (for example /ords/health_api/health/ping, depending on your schema alias) and expect HTTP 200. Restrict it to internal callers if you do not want it public.
10. Step 8 – Make the database highly available too
Two ORDS nodes do not help if the single database goes down. Match the database protection to the business need:
| Option | What it protects against | Notes |
|---|---|---|
| Single instance + backups | Data loss | Downtime while you restore. See RMAN and Data Pump backups. |
| Data Guard (standby) | Server or site failure | Fail over to the standby; ORDS connects through a service that follows the primary. |
| RAC | Instance failure, scaling database CPU | ORDS connects to the SCAN address and service; work continues on surviving instances. |
If ORDS uses a custom connect descriptor, include both addresses with failover:
(DESCRIPTION=
(CONNECT_TIMEOUT=5)(RETRY_COUNT=3)
(ADDRESS_LIST=(LOAD_BALANCE=on)(FAILOVER=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=db1.local)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=db2.local)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME=apexprod)))
11. Step 9 – Test everything, including failure
- Login and navigation: log in through
https://apex.yourcompany.com/ords/, open several pages, submit forms and upload a file. - Which node served the request: check each node’s access log while you click; requests should spread across nodes.
- Failover: stop ORDS on node 1 while logged in. Keep working – pages should continue to load from node 2 without logging you out, because the session is in the database.
- Recovery: start node 1 again and confirm the load balancer puts it back in the pool.
- Load test: use a tool such as JMeter or k6 with realistic user journeys, and watch database sessions, CPU and ORDS pool usage.
- Emails and links: confirm that links in emails sent by APEX use the public URL, not an internal hostname.
12. Common problems and fixes
| Symptom | Usual cause | Fix |
|---|---|---|
| Redirect loop or 403 after login | ORDS does not know the request was HTTPS | Send X-Forwarded-Proto: https and set security.httpsHeaderCheck |
| Missing styles or icons on some requests | Different or missing /i/ images on one node |
Copy the same images version to all nodes, or use the CDN |
Links show app1.local:8080 |
Host header not forwarded | proxy_set_header Host $host; |
| File uploads fail | Load balancer body size limit | Increase client_max_body_size |
| 504 Gateway Timeout on big reports | Proxy timeout shorter than the request | Raise proxy_read_timeout, and tune the report – see APEX performance tuning |
| “No more data to read from socket” / pool exhausted | Pool too small or database session limits | Tune jdbc.MaxLimit and database sessions/processes |
| Errors only for some users | Nodes configured differently | Compare ords config list output on every node |
13. Production checklist
- Two or more ORDS nodes with identical version, configuration and APEX images
- Load balancer with SSL, HTTP→HTTPS redirect and forwarded headers
security.httpsHeaderCheckset on every ORDS node- Health check that tests the database connection
- Connection pools sized against database session limits
- Database high availability matched to the business need (Data Guard or RAC) and tested backups
- ORDS ports reachable only from the load balancer
- Failover tested by stopping a node during a live session
- Monitoring of node health, response time, pool usage and database load
Frequently asked questions
Do I need sticky sessions to load balance Oracle APEX?
No. APEX stores session state in the database, so any ORDS node can serve any request. Sticky sessions are optional.
Can I load balance APEX on Windows Server?
Yes. Run ORDS as a Windows service on two or more servers and use a load balancer in front, such as Nginx, HAProxy, IIS Application Request Routing or a hardware or cloud load balancer. The ORDS settings are the same.
How many ORDS nodes do I need?
Two is the minimum for high availability. Add nodes when CPU or connection pool usage on existing nodes stays high during peak hours. Often the database, not ORDS, is the real limit, so measure first.
Does load balancing make a slow APEX page faster?
Not by itself. It spreads users across servers and removes a single point of failure, but a slow query is still slow. Tune the SQL and page design as well.
Can I use Oracle Cloud (OCI) Load Balancer instead of Nginx?
Yes. Create a backend set with your ORDS nodes, an HTTPS listener with your certificate, a health check, and make sure the X-Forwarded-Proto header reaches ORDS. Oracle Autonomous Database already includes managed ORDS, so separate load balancing is usually only needed for customer-managed ORDS.
Related guides: install Oracle 19c, APEX and ORDS, Oracle APEX performance tuning, Oracle APEX 26.2 installation and upgrade, Oracle 19c backup basics and Oracle APEX tips and tricks.
Need high availability for APEX?
Get your load-balanced APEX and ORDS setup done for you
AbairTech plans and configures multi-node ORDS, Nginx load balancing, SSL and failover testing for Oracle APEX, then supports your applications. 12 years of Oracle experience, Oracle Certified APEX Cloud Developer.
Need a highly available Oracle APEX setup?
AbairTech installs, scales and supports Oracle APEX, ORDS and Oracle Database for ERP, HRMS and business systems – on-premises and in the cloud.