Re: Dynamic Session Creation
Hi Nick and others, I'm making some progress on the implementation of the dynamic session handling. Basically, the backend part is completed. As I wanted to be independent of the cloud provider and also wanted to allow the mechanism to work for on-premises installations, I use a resource management system common in the HPC world (SLURM) to organize the sessions on a cluster of session host instances, i.e., I can create a session request for a user (in fact it's a script describing how to startup the X-display, the window manager, etc. which is submitted to the queueing system and then gets executed on one of the session host instances). There is also a mechanism to add the session information (remote host, display port, VNC password, etc.) to the Guacamole database automatically once the session is ready to accept connections. For cloud setups, instances are automatically deployed, if there's not enough capacity on the already running instances. It works nicely so far. I'm now facing the challenge of triggering the backend mechanism from the web-app as well as reporting progress information from the backend to the client. I'd like to achieve the following: When a user logs in to Guacamole with valid credentials and there's no active session for this user, then the backend mechanism should be triggered and start the session creation and, if required, the creation of a new instance which can host the session. Although I can use an Guacamole event listener to trigger the backend process which creates the instance and the session for the user, the creation process can take 2-3 minutes before it arrives at the point where the session is ready to connect (because the instance needs some time to start up). The challenge is now to "inform" the user about what's going on in the backend during the time he/she waits for the desktop to appear, i.e., I'd like to just show a dialog box which displays the information it gets from the backend, like: Instance is created. Desktop is prepared. etc. I tried to wait in the event listener, which creates the session, until the session is ready, but this creates a horrible user experience, of course (web app is unresponsive during that time). I was looking in the Guacamole code and it seems that guacamole/src/main/webapp/app/client/controllers/clientController.js contains the status messages displayed during the connection setup and also the code for periodic re-connection if there is a backend issue (in my case: session is not yet ready). Maybe someone knowing the internals of Guacamole can enlighten me whether that's a promising place to implement the status messages and the communication with the backend. Thanks for any help! Am Mi., 30. Mai 2018 um 19:08 Uhr schrieb Nick Couchman : > On Sun, May 20, 2018 at 4:58 PM, Felix Wolfheimer > wrote: > >> Hi Nick, >> >> thanks for your answer. Yes, I was talking about VNC sessions on Linux. >> The scenario I have in mind is a cloud deployment with auto-scaling >> functionality: >> >> There's one instance where guacamole is installed. This instance is >> small, cheap, and runs 24/7. The applications used in the VNC sessions >> require decent 3D rendering performance and, thus, I want to host them >> on GPU instances. These instances are expensive and so I would like to >> only spin them up when there's demand for a session. I have a mechanism >> that can submit a script (which creates a VNC session) to a scheduling >> system (e.g. SLURM). This scheduling system is connected with an >> autoscaling mechanism, e.g., cfncluster, which starts session host >> instances if there's demand. The session starts on the new instance, >> and the session information is added to the guacamole_db. >> This is why I was thinking the it would be great to have a mechanism to >> trigger the submission of the session creation script to the scheduling >> system when a user logs in. As the start of an instance needs a moment, >> I would like to have some way to inform the user about what's going on >> in the background. >> > > > That makes sense. You should be able to do something like this in a > Guacamole extension - monitor the number of users connected to a particular > connection or connection group, and then trigger something every time > there's a connect or disconnect. I would imagine the most useful thing > would be event listeners: > > http://guacamole.apache.org/doc/gug/event-listeners.html > > If you trigger an action every time a connection is established or > terminated, you can scale it in such a way that you always have 1 or more > spare instances running (depending on how frequently and quickly you expect > users to connect), and that would do the trick. If you wanted to go even > leaner than that, you could trigger it at user logon/logoff such that an > instance was started when a user logged on to Guacamole, and, if there was > sufficient time between logon and the user attempting to connect, this > might work, as well, with
Re: Dynamic Session Creation
On Sun, May 20, 2018 at 4:58 PM, Felix Wolfheimer wrote: > Hi Nick, > > thanks for your answer. Yes, I was talking about VNC sessions on Linux. > The scenario I have in mind is a cloud deployment with auto-scaling > functionality: > > There's one instance where guacamole is installed. This instance is > small, cheap, and runs 24/7. The applications used in the VNC sessions > require decent 3D rendering performance and, thus, I want to host them > on GPU instances. These instances are expensive and so I would like to > only spin them up when there's demand for a session. I have a mechanism > that can submit a script (which creates a VNC session) to a scheduling > system (e.g. SLURM). This scheduling system is connected with an > autoscaling mechanism, e.g., cfncluster, which starts session host > instances if there's demand. The session starts on the new instance, > and the session information is added to the guacamole_db. > This is why I was thinking the it would be great to have a mechanism to > trigger the submission of the session creation script to the scheduling > system when a user logs in. As the start of an instance needs a moment, > I would like to have some way to inform the user about what's going on > in the background. > That makes sense. You should be able to do something like this in a Guacamole extension - monitor the number of users connected to a particular connection or connection group, and then trigger something every time there's a connect or disconnect. I would imagine the most useful thing would be event listeners: http://guacamole.apache.org/doc/gug/event-listeners.html If you trigger an action every time a connection is established or terminated, you can scale it in such a way that you always have 1 or more spare instances running (depending on how frequently and quickly you expect users to connect), and that would do the trick. If you wanted to go even leaner than that, you could trigger it at user logon/logoff such that an instance was started when a user logged on to Guacamole, and, if there was sufficient time between logon and the user attempting to connect, this might work, as well, without having to keep as many (any?) spare instances. The other option is to use an external load balancer to accomplish this and then just point Guacamole at the load balancer. I'm all for implementing cool extensions for Guacamole, but this may have some benefits, particularly in cloud-type environments where you're given these tools. I'm thinking of AWS where you can do EC2 + Elastic Load Balancer (ELB) and ELB will actually manage the number of spare EC2 instances for you. The plus side to this is that, at least in the case of AWS, it's already implemented. You can also do some similar stuff with a load balancer like HAProxy, where you can look at the current user count vs. maximum count and start up or shut down instances with a script of some sort based on that. I've done this in the past and it worked reasonably well. Anyway, plenty of possibilities for you - post back and let us know what you do and how it works! -Nick
Re: Dynamic Session Creation
Hi Nick, thanks for your answer. Yes, I was talking about VNC sessions on Linux. The scenario I have in mind is a cloud deployment with auto-scaling functionality: There's one instance where guacamole is installed. This instance is small, cheap, and runs 24/7. The applications used in the VNC sessions require decent 3D rendering performance and, thus, I want to host them on GPU instances. These instances are expensive and so I would like to only spin them up when there's demand for a session. I have a mechanism that can submit a script (which creates a VNC session) to a scheduling system (e.g. SLURM). This scheduling system is connected with an autoscaling mechanism, e.g., cfncluster, which starts session host instances if there's demand. The session starts on the new instance, and the session information is added to the guacamole_db. This is why I was thinking the it would be great to have a mechanism to trigger the submission of the session creation script to the scheduling system when a user logs in. As the start of an instance needs a moment, I would like to have some way to inform the user about what's going on in the background. As you confirmed that something like this may work, I'll look a bit more into the Guacamole extension mechanism. Best regards Felix signature.asc Description: This is a digitally signed message part
Re: Dynamic Session Creation
On Sat, May 19, 2018 at 1:13 PM, Felix Wolfheimer wrote: > Hi all, > > I'm currently trying to figure out if and how a dynamic session creation > mechanism can be implemented in a Guacamole extension. Let's say I have a > bunch of machines which can host graphical desktop sessions and I have a > script based mechanism to initiate the request to create such a graphical > session on one of the machines and add the information about the session > into the guacamole_db (SQL). If a user, who doesn't own a graphical session > yet, logs in to Guacamole, I'd like to trigger/call the script in the > backend which creates the session and adds the information to the > guacamole_db. > Can you explain a little more what kind of graphical session you're talking about, here, and why the creation of the session needs to be scripted? I'm presuming you're talking some sort of VNC session, since RDP doesn't usually require any setup, but maybe you can clarify this a bit? Even for VNC you can set it up with xinetd such that sessions get created when users connect, so some additional information here on what exactly you're trying to do would be helpful. > > I've looked through the extension mechanisms in Guacamole and it seems > that event listeners could be used to trigger the mechanism in the backend > on user login. Has someone knowing the architecture of Guacamole an idea > whether > > - the user will be connected to the just created session, if the session > creation is done in a listener on an "AuthenticationSuccessEvent" happens, > - there's any way of informing the user about what's going on in the > backend from within such a listener function (e.g., display a banner > "Session creation pending. Please be patient." or something similar, until > the session is ready for connection). > > You should be able to implement an extension which implements the AuthenticationSuccessEvent and performs whatever action you'd like to do upon authentication. Your extension should also be able to make the connection happen automatically - in addition to writing the event listener implementation, you'll likely need to write some AngularJS code and perhaps even a REST endpoint in order to pass information about the newly-created session between the Java back-end and the web browser front-end and make the connection happen, but this should be doable. It's definitely a little bit involved, but it all sounds doable. Sounds like you're already reading the manual, which should be a good place to find that information, so I'd just continue to look through that and the existing code to figure out how to do what you're trying to do. You can also e-mail back here with any specific questions you might have and the community will jump in and help as we can :-). -Nick
Dynamic Session Creation
Hi all, I'm currently trying to figure out if and how a dynamic session creation mechanism can be implemented in a Guacamole extension. Let's say I have a bunch of machines which can host graphical desktop sessions and I have a script based mechanism to initiate the request to create such a graphical session on one of the machines and add the information about the session into the guacamole_db (SQL). If a user, who doesn't own a graphical session yet, logs in to Guacamole, I'd like to trigger/call the script in the backend which creates the session and adds the information to the guacamole_db. I've looked through the extension mechanisms in Guacamole and it seems that event listeners could be used to trigger the mechanism in the backend on user login. Has someone knowing the architecture of Guacamole an idea whether - the user will be connected to the just created session, if the session creation is done in a listener on an "AuthenticationSuccessEvent" happens, - there's any way of informing the user about what's going on in the backend from within such a listener function (e.g., display a banner "Session creation pending. Please be patient." or something similar, until the session is ready for connection). Thanks for any answer or tip.