simple bbb loadbalancer
I've added a very simple loadbalancer function. Every meeting has a unique meetingID. The bbb-server to use is choosen in dependence of this ID. So every meeting will allways use the same bbb-server and there will be no problems to find recordings. It's not a real loadbalancer. Every bbb-server will get approximately the same number of meetings. This does work very reliable. I take the ascii value of the first character of the meetingID modulo 2 to choose the bbb-server. It's very easy to enhance this for more servers. The only requirement is that every server must have the same bbb-secret.
Here is the very simple but efficient code:
$p=strpos($params, 'meetingID=');
if($p !== false)
{ if(ord(substr($params, $p+10, 1))%2 == 0)
{ $this->bbbServerBaseUrl="https://SERVER2/bigbluebutton/";
}
}
Included in the file /apps/bbb/vendor/littleredbutton/bigbluebutton-api-php/src/Util/UrlBuilder.php at line 59 in function buildUrl.
I'm not familiar with the app code so it's maybe not the right place to include. Maybe there is interest to include this officially in the bbb app in a more professionel matter. I've hardcoded the url of the second bbb-server. There should be the possibility to do it in the admin section.
Thanks for sharing this snippet with us. Yes such an bucket approach would be the easiest, but I'm wondering what the use case would be. I guess if you use more than 2 servers you should use a full blown load balancer and therefore it's probably a bit too much effort to implement this.
In case someone wants to add this, here are some remarks:
- should probably included in https://github.com/sualko/cloud_bbb/blob/master/lib/BigBlueButton/API.php
- admin page has to be extended to support multiple server/secret tuples
-
API::getVersion()has to be adapted to always require a url - instead of the meeting id, the room uid should be used (otherwise methods like
isRunningwill not work)
You should not use this. Please use a solution like Scalelite instead.
Definately second @sebastianberm 's opinion on this case, refer to Scalelite when it comes to loadbalancing BBB-Servers. The plugin should not try to implement any kind of load-balancing as it only complicates the original purpose of this add-on.
Thanks to @kdmoeller , this seems to be a very smart solution for people who just want to connect one more BBB-server. Scalelite would be the more enhanced solution, no doubt about it - but if you just have 2 BBB-servers scalelite is a bit overkill, I think. With this little code you don't need an additional server for balancing and it seems to work pretty well. I did not had any problems with it yet. I did as kdmoeller explained, no success using it in api.php or with room uid - I think that would take a little time to figure that out.
O.K., now I've found an issue: Recordings of both servers are listed, working and accessible, but deleting a recording is only possible for those of the "main" BBB-server. For deleting a recording of the "side" BBB-server ,the BBB URL must be changed in the admin settings. This is, I think, something that could be easily fixed with the right code in api.php. It would be great if someone could port the idea of @kdmoeller and paste the code in the way @sualko suggested. I know, this is no real loadbalancing. However, if you just want to split the users' rooms over two servers, this is a super simple solution. I would also support this idea with a fee if it helps. :-)
Just a question @sebastianberm . You are using ScaleLite with Klaus' nextcloud app, right? How do you handle recordings, does the nextcloud app recognize recordings on the scalelite server or would it be better to leave recording of the bbb servers when using nextcloud?
Hi @spreeni151, We're not using Scalelite, but have built our own system, as Scalelite has a couple of things we didn't want. You will want to use Scalelite with it's recording importer to make sure this works correctly. In that case, Nextcloud will query the API of Scalelite, which will in turn know which files / url's to serve back. So this is 100% possible and compatible.
There is supposed to be an import event handler for published recordings on the end of BBB itself, which takes care of transferring the data to the scalelite server/services.
Edit: we did do a thorough analyses of what Scalelite does and how it works before we started, so it's quite easy for me to explain or talk about how it works and how certain components work with eachother. (And no, our system isn't compatible with the codebase, but we do take a look at the upstream to see if we're missing certain items...)
There are currently multiple alternatives in development since Scalelite has some, let's say, shortcomings. One of them is https://gitlab.com/infra.run/public/b3scale. It would be interesting to evaluate how a complicated load balancer works, compared to the simple approach suggested above. My guess would be that there is no big difference. Especially if you would add the power of two choices to have a better distribution.
As I said this is currently out of my scope, but if someone has time it would be a nice addition.
Thank you @sebastianberm for your explanations. This helps me configuring our scalelite setup. As I wrote in another post I had problems to get scalelite work together with the bbb app. So thank you @sualko for pointing to b3scale which could be an alternative. Btw, very nice doc about 'power of two choices'. My feeling is that this would be a great addition to the app's functionality. I understand that further development takes time and is difficult to implement as freeware. Would it help if I asked our association to sponsor this function? What amount should they expect for implenting such a 'simple' balancing option?
see my solution which has everything but recording and has been working fine with this plugin for months now: https://github.com/hmt/tinyscale