We’ve been using the NX Terminal Server (version 6.3.6) product for a few months. When we reach about 1,5k sessions the terminal server fails assigning new sessions for new users.

Because I can’t play with the productive environment I had to figure out how to make a “stress test” similar enough to replicate the issue by generating multiple sessions and logins with one NX client to the terminal server. In this article I’ll explain how you could achieve a similar task.

Searching on google the closest thing I’d found was benchmark tests on an NX environment. Nothing was explicit but its indications were enough to have an approach.

Using guest accounts

I must be clear with this: Guest accounts in multinode environment do not work at this moment! you can check that link to see if that feature is corrected in newer versions (yes it was fixed in version 6.5.6), the problem is that guest accounts are “logged in” but the login process is never completed. That means the sessions and guest users are created but you will never get a desktop as guest user on a multinode environment.

But, for my particular needs it was enough, because I just wanted to generate multiple sessions and it was happening, so here we go with it, you can modify the template to use other kind of users with passwords or even private keys.

Prepare the template

You’ll need a template to automate the task. Here you have a copy of my template with guest sessions enabled, do not forget to modify the value in <option key=”Server host” value=”myserverofnomachine.domain” /> with your own NX server.

Then, we’ll need multiple templates to generate multiple connections (it doesn’t matter if you use user/password/private key or guest accounts) in case of guest accounts the client will place a user and encrypted password on each template, remember each password will be encrypted in this way.

To generate multiple templates you could execute:

This will just copy the original template provided before into 100 new templates “my_template_1, etc…”.

Now that we have so many templates it’s time to generate many connections, we can achieve that in this way:

  • The previous command do a loop from 1 to 100
  • Then executes /bin/bash to span a new subprocess each time (otherwise you should wait to close the current connection until the next is generated and we want multiple sessions one after another).
  • The sleep 7 just makes you wait 7 seconds after calling each !m session, you could directly remove this if you want the consecutive logins faster.

The result, many instances of the NX client spawned:

No machine multiple sessions generated.

No machine multiple sessions generated.

At server level we can monitor the sessions being created with:

The guest name will be increased each time you generate new guest connections.

It was all fun and games until the system started to fail:

So maybe isn’t completely similar to my productive environment but its useful as reference when I’m allowed to do something similar on production.