Multiple BaseURLs (OpenHab Cloud instances)

  • Platform information:
    • Hardware: Cloud (AWS EC2)
    • OS: Ubuntu

Hello,

I have OpenHab Cloud server running on two servers, both of which are behind a single load balancer.
I’ll refer to them as:

  • LB (Load Balancer)
    – OH 1 (10.0.0.50)
    – OH 2 (10.0.0.60)

I can configure Paper UI (Client) with 10.0.0.50 as baseURL and it works, the /start/index page is accessible. I can also do the same for OH 2 (10.0.0.60), but OH 1 stops working, as expected.

Would it be possible to have two baseURLs configured in order to send data to both OpenHab Cloud servers? Or is there another (better?) way to run OpenHab Cloud server in a high-availability environment? I’d like to eliminate SPOF anyway possible.

1 Like

Looping in @digitaldan

The load balance switch I use at work would also have a virtual address usually used to access and load balance across the servers. The ssl certificate in this case lives on the load balance switch.

The whole point of a load balancer (LB) is that the clients to the service only talk to the LB and the LB then forwards the requests to one of the instances of the service behind the scenes. Thus, as Bruce indicates, you need to put the IP of the LB into the browser, not the IP addresses of the services behind the LB. In fact, strictly speaking, 10.0.0.50 and 10.0.0.60 shouldn’t even be accessible by anything but the LB.

Notice though that you’ve just moved the SPOF to the LB. There will always be a SPOF somewhere. It’s simply not worth the cost and effort to make a truly redundant system (e.g. two connections to the Internet from two different providers, physically separated servers by large distances like across the country, etc).

1 Like

At work I have some load-balanced servers that are located in 2 data centres about 1 mile apart. The load balance switch is a cluster of 2 with one in each data centre . Each switch is connected to both data centres but only one is active at a time.
This configuration permits network redundancy in addition to being able to scale up load capacity. Some protocols, such as RADIUS require special handling by the load balance switch to insure all packets for a single session go to the same server.

Thank you for your reply.

Configuring the OpenHab client with the load balancer was the first thing I did, but one of the OpenHab servers was stuck in a loop trying to retrieve the list of devices from the client (OH 0 - 10.0.0.40).

Configuring Paper UI on the client (OH 0 - 10.0.0.40) with the IP address of one of the OpenHab servers ( OH 1 - 10.0.0.50) resulted in the master (OH 1 - 10.0.0.50) being able to retrieve the list of devices and work as expected when accessed directly.

Configuring Paper UI with the load balancer’s IP/hostname would work sometimes and fail randomly. This is because the load balancer could be sending client traffic to OH 2 (10.0.0.60), while users connecting to the web interface via the LB try to retrieve data from OH 1 - 10.0.0.50.

The problem: The OpenHab server must receive data from the clients to work.

This is why I was hoping I could configure multiple baseurls like the following or similarly so traffic from the client is constantly being fed to both OpenHab server instances:

baseurl = http://10.0.0.40,http://10.0.0.50

I hope this clarifies the issue I have. If it doesn’t, please let me know and I’ll try to improve my reply.
I look forward to any helpful responses and appreciate all responses received so far.

1 Like

I think it’s worth stating the following.

  1. OH is not commercial nor industrial grade software. It was created and is intended to be used in a home automation context.

  2. Almost all of the time, the software being load balanced needs to be load balancing aware. If it is not, then they need to use a shared back end which maintains all of the state. The servers themselves are then essentially stateless and any information they need comes in on the request or is pulled from the shared back end.

Put another way, services need to be designed and built to support load balancing. OH Cloud Server was not designed that way.

Sending all data to all instances of the cloud server behind the Load Balancer would defeat the whole point of having a load balancer. You are not spreading the load across multiple instances, you are requiring multiple instances to do all the work for every request.

PaperUI is a web based application. It’s a web page. You can’t configure multiple base URLs without essentially replacing every link in the UI with two links. It’s not like you can just change some variable somewhere and have it work. And even if you could, that would be what is often called an anti-pattern. That’s not how it is supposed to work.

If you want to make this work, you need to figure out how to have both PaperUI instances share the same data. That means making them at a minimum share the same MongoDB instance but it likely will also require changes to the code if there is state carried internally in memory.

2 Likes

It might not have been designed that way, but it is not impossible.
myopenHAB is running on 3 App servers behind a loadbalancer.
@digitaldan Could you share some details how you did our setup.

2 Likes

They are likely paying a single cloud or hosting provider to load balance. That provides additional load capacity but not redundancy
Unless you are planning on selling the cloud services to others, you should not need the load capacity that requires multiple cloud instances…

Right on, i think digital dan is best to comment on how myopenhab.org does this.