Building a Better Ngrok

Shivansh Vij
6 min readApr 28, 2020

--

Lynk Beta

Today, working from home is the norm. Practising increased social distancing to stop the spread of Covid-19 means you can no longer go into the office and connect to your private network, and you can’t meet with clients in person to demo your work. Some companies are implementing VPNs to circumvent these issues, but VPNs can be clunky, and because they expose your entire private network, they can also present a significant security risk — especially if you need to share public access for demos to clients.

This is why so many companies are switching over to tunnelling. If VPNs are satellites, then tunnels are microscopes. Instead of exposing your entire network, tunnels only allow traffic to a specific service within your network. This keeps your network secure, and allows you to share your tunnel with clients without any worries.

The downside to tunnels however, is that they can be difficult to setup and maintain, or they can be expensive. Companies like Ngrok exist that provide Tunnels as a Service (TAAS), however they fall into the expensive category, putting necessary features like custom domains and subdomains behind heavy paywalls. They are also not available for self-hosting which is an issue for a lot of people.

This is where Lynk comes in. From the beginning my goal has been to build a better ngrok. Cheaper, Faster, and with more features — including self-hosting.

On March 23 we released the Lynk Alpha, and with that we received an incredible amount of both support and feedback from the developer community. The biggest thing people wanted to see was a speed increase. When we designed Lynk we were focused mostly on security and stability so when we saw that Lynk was about as fast as Ngrok we thought that was good enough for an initial release.

But now it’s time for the Lynk Beta, and we aren’t okay with just “good enough”. We want Lynk to be the industry standard for secure Tunnels, which is why we went ahead and spent the last month optimizing Lynk’s tunnelling protocols to be as fast as possible.

We used the open sourced tools from https://www.sitespeed.io/ to run our benchmarks against ngrok in the same environments.

Here was the setup:

Host the Nuxt.js source code for https://lynk.sh on a Microsoft Azure VM, and run the development server on localhost:3000. Next, install both ngrok and Lynk on that VM and run the tunnels one at a time for the sitespeed.io tests.

It was important to use the Azure Cloud because Lynk’s infrastructure runs on Digital Ocean — this means that if we hosted it on Digital Ocean we would have more than likely had an unfair advantage.

For the client side testing we were running a Macbook Pro 16" with 16gb ram and an Intel i9 processor. During testing I was the only one on my network and used a wired connection to the modem.

Disclaimer: The numbers shown below are for the Nuxt.js development server. This means the code is not minified, and extra tools like hot-reloading support are being loaded with the website. This is important because this is how developers will more than likely use Lynk. The ability to demo your website to a client, and be able to make live changes that will load directly into their browser is an incredibly useful feature. If we had used the production version of our website we would see the same trends as below, just with lower metric values.

Sitespeed’s tools return a couple of metrics which we’ve graphed and explained below:

DOM Interactive Time — Lower is Better

DOM Interactive Time is the time immediately after the browser has finished parsing all of the HTML and DOM construction is complete. This is important because often this is the time when the user has started to see an actual semblance of the website. The results above show that Lynk is consistently significantly lower in the interactive time than Ngrok except for Run 5, however as we’ll see Run 5 is an outlier across all metrics.

These results were very exciting because they meant that a website served with Lynk could load up to 6x faster than if it were using ngrok.

First Paint Time is the time before the browser has enough information to paint the first pixel onto the user’s screen. Lower is better here because the faster the browser paints the less time that the user is left starting at a blank screen. In this both Lynk and Ngrok are very similar, with Run 5 being an outlier for Lynk as seen in the earlier test.

Page Load Time (Lower is Better)

The most important metric of all is the Page Load Time. This is the average amount of time before whole the page has shown up on your screen, all subresources loaded and all the CSS applied. Being fast here is critical because this is one of the clearest performance metrics.

It is clear from the data above that Lynk is significantly faster than Ngrok in this metric as well — by more than 4x in some cases. Run 5 is still an outlier, however on average the results are clear.

Sitespeed also averages this data for us and returned the following results:

We can see from this that for the same number of request (28), Lynk’s backend and first paint time is about the same as Ngrok (within the margin of error). However, the average load time using Lynk for the entire page is almost twice as fast as what Ngrok offers.

As significant as this is, the final metric that really runs things home is the RUM Speed Index. RUM stands for Real User Monitoring and is the best metric for measuring how your website will look and feel for your users — and if the website will feel sluggish while they interact with it. The lower the score, the better.

Ngrok’s RUM Speed Index is almost twice as high as Lynk, which means that on average websites will feel about twice as sluggish as those loaded with Lynk.

Thanks for Reading!

The Lynk Beta will run from April 26, 2020 to May 8, 2020, after which we also plan on launching the Self-Hosted version of Lynk. Pricing for Lynk will be competitive with Ngrok at $5/month for the pro plan, and will include features such as custom domains (not subdomains of lynk.sh, but completely custom domains), HTTP authentication, and much more.

Lynk supports TCP Traffic, WebSockets, and HTTP/2, and all tunnels are TLS encrypted end-to-end.

You can find out more about Lynk at https://lynk.sh, and more about me at https://shivanshvij.com.

Check us out on Product Hunt:

--

--

Shivansh Vij

Software Engineer @ Banyan Security, 3rd Year Computer Engineering Student @ UWaterloo