Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 17, 2019 09:58 am GMT

Developing 10x faster with a Surface Go, thanks to VS Code and Azure

As developers we always seek to have the most efficient environment, and that often means buying a high-end laptop. We're going to see in this post that using VS Code Remote Development with Azure can provide a much better environment, for a lower cost.

I believe this is a revolution for consulting companies and freelancers, and that this could change the way we work in the future.

But let's start with a story!

The Surface Go, an awesome machine for developers?

I currently bought myself a Surface Go for my own personal use. This was before I worked at Microsoft, and in fact is totally unrelated to my work activities. My reasons were that :

  • It's extremely light and small
  • It's very cheap, on Amazon there are always discounts and you can get them for less than $500
  • It has Windows 10 with its applications store, including Netflix (a must-have for anyone with kids, as we all know how those offline "Paw Patrol" episodes are useful when traveling)
  • It has a UBS-C port, so I can just plug it into my monitor I have for work (Dell UltraSharp 27 - U2719DC) and everything works out-of-the-box

Very important note : there are 2 editions of the Surface Go, use the high-end one. Not only do you have double the RAM and disk, but also you have a real SSD disk which is much faster.

Of course, as a developer, I'm also using it to code, so the question is : how good is this for coding ?

My development setup

I set up everything using the awesome Chocolatey package manager, including :

Initial performance numbers

As the lead of the JHipster project, I'm of course doing those performance tests with a JHipster application, but there's nothing really specific to JHipster here, so they should be the same for about any Java process, or even any process that uses quite a lot of CPU, RAM and disk.

I created a simple project at https://github.com/jdubois/simple-jhipster-app, which you can test on your own machine easily :

  • Clone the project : git clone [email protected]:jdubois/simple-jhipster-app.git
  • Run the Maven wrapper : ./mvnw

From a performance point of view, this doesn't look very good :

  • Maven takes a long time to run
  • Spring Boot starts in 13.5 seconds

Let's see how we can improve this!

Surface Go vs. Surface Book

Thankfully, for work I have a mid-range (core i5) Surface Book, so it should be better with that hardware, isn't it?

I've installed the same setup on this machine : starting the Spring Boot application takes now 12 seconds, instead of 13.5 seconds! What we are doing is a bit dependant on the CPU, but most of our problems are probably I/O related, and both hardware have the same memory and probably a similar SSD.

So, first interesting lesson from a cost perspective : buying a $500 Surface Go is a very good deal here, as it costs a quarter of the price of the Surface Book, and is also quarter of the weight in your backpack!

Using VS Code and removing Maven

Let's open the application using Visual Studio Code Insiders, and install of course the "Java Extension Pack" from Microsoft.

As Spring Boot applications are also normal "Main" Java classes, it is possible to simply run the application by running its main method, in the SimpleApp class. It's much easier than running Maven, but also much faster. And you can also debug the application with one click!

We are now gaining the Maven start-up time, but the application still starts in 13.5 seconds.

Using VS Studio Code Remote Development

Open up again Visual Studio Code Insiders, and install the "Remote Development" extension from Microsoft.

This will allow us to work on a SSH machine, that will be provided by Azure.

Let's create the virtual machine on Azure :

  • Go to the Azure portal.
  • Create a new virtual machine.
  • Choose the default machine type, D2Sv3 at the time of this writing. This costs $0,1120 per hour.
  • Add your public key on the first screen, and in the networking screen, don't forget to open the SSH port in the Select inbound ports drop-down list.
  • Keep all the other options by default, and create the machine.

Once the machine is created, let's configure it with our usual working environment. I personally have my own setup script, which you can of course reuse :

  • The script is available at https://github.com/jdubois/jdubois-configuration/blob/master/install.sh
  • Login to your new Azure virtual machine using SSH : ssh username@machine-ip (please note you can find your machine's IP address on its "overview" page on the Azure portal), and become root : sudo su
  • Once you are logged in, run my installation script as root : sh -c "$(curl -fsSL https://raw.githubusercontent.com/jdubois/jdubois-configuration/master/install.sh)"

Congratulations, your Azure machine is ready!

Let's go back to VS Code and connect to it. As we will use this SSH connection quite often, I recommend that you create a .ssh/config file in your home folder, with a setup similar to this one :

Host jdubois-azure    HostName 52.232.60.209    User julien

Once you are connected to the Azure virtual machine :

  • Use the extension management tab to install the "Java Extension Pack" from Microsoft again, but this time on the remote SSH host.
  • Use the command palette to do a Git clone of our sample application https://github.com/jdubois/simple-jhipster-app.git.
  • Run the SimpleApp class as we did before.

As a result, our application now starts in 10.3 seconds! That's a bit better than on our Surface Go, but clearly the default Virtual Machine isn't the best option for us.

Please note that if you want to access your application locally on http://localhost:8080, the "Remote Development" tab gives you a graphical utility to create an SSH tunnel.

Testing with better machines, and optimizing price

As we are using Virtual Machines, there are a few very interesting things we can do to optimize both our costs and performance :

  • Those machines should only run when you use them, so you should turn them on and off when you work, like a normal computer in fact! Please note that there is an "Auto-shutdown" menu on the Azure portal, and it's probably a good idea to shut down machines automatically for the night or the week-end, in case you forget to do so.
  • There is a "Size" menu, which allows you to change the machine type you are using, in order to tune it depending on your desired cost and performance. This doesn't work for all machines, unfortunately : they need to be in the same region, and in the same family.

Let's run our test again, and see the best performance we can get for our application, and calculate its daily associated cost (we are considering here that you work 10 hours per day, 240 days per year). Here are the results, with the associated cost (for the "West Europe" region), with the machines which looked the most promising :

Machine typeApplication start-up timeDaily cost (10 hours)Yearly cost (240 days)
D2S v3 (default)10.3 seconds1.20288
F2s v25.8 seconds0.97233
F4s v24.0 seconds1.94466
F8s v23.4 seconds3.88931
H82.9 seconds10.322,467
H8 Promo2.9 seconds6.201,488

Let's study those numbers :

  • The default machine (D2S v2) isn't very interesting : it's 30% faster than the Surface Go, so it's not really worth the price and the trouble.
  • The "F" machines, which are the "compute-optimized" machines on Azure. Starting with the "F4s" they also have access to premium SSD and accelerated networking, so you get more than just CPU power when you upgrade.
  • The "H" machines are for "High performance compute", so basically they have better CPUs than the "F" machines. However, they are much more expensive, and as we saw earlier we are not that much CPU-dependant. Currently there is a "Promo" on some of them, which makes their price more attractive, and in that case they can be an interesting alternative to "F" machines.

As a result, it does seem the "F" machines are the best deal. I would personally use either F4s v2 or F8s v2, and use the "resize" feature to switch depending on my needs. As I have an MSDN subscription, I have $130 of Azure credits every month, so even the H8 Promo could work!

Conclusion an thoughts

Clearly, running our application on "F" machines types is much faster than on the Surface Go, for a reasonable price. Also, we are able to "resize" and shutdown those machines in order to adapt to the cost and performance we require.

For consulting companies and freelancers, I believe there is here a very compelling alternative to the usual $2,500 Macbook Pro that everybody currently buys :

  • The upfront cost is very cheap (about $500), so buying one isn't such a big decision as with a MacBook Pro.
  • It's the usual CAPEX vs OPEX calculation we do with the cloud : as a consultant, I'd rather not spend those $2,500 when I start my business, but rather spend a few Dollars each day, depending on my billable work.
  • I believe those few Dollars per day could be billed to customers : this doesn't cost much (compared to how much consultants bill their time!), wins time on people on-boarding, and gives better security (code isn't copied on everyone's laptop).

Original Link: https://dev.to/azure/developing-10x-faster-with-a-surface-go-thanks-to-vs-code-and-azure-mho

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To