DEV Community

Rishabh Gupta
Rishabh Gupta

Posted on

Going Cloud

I few weeks back I decided to try out a new workflow for my assignments and projects. This involved doing all my work on a remote server including coding, compiling and checking output.

Reason

The main reason I wanted to try this out was because I hated carrying my laptop to college everyday (its almost 2.7kgs) and wanted a workflow that can be easily ported and can work from anywhere. I also had 100$ digitalocean joining credit which I thought could be put to good use.

Setup

This was an easy part. All I needed was to create a virtual machine and install necessary language tools.
I went with the stable ubuntu 16.04 vm and installed Python, Nodejs and cloned my projects from github.
Now take care to select a vm near to your location, as this will decrease latency and improve the overall experience

First tries : sshfs

I was reluctant to give up the comforts of my favorite editor so I thought I could mount the remote server as a folder and then open those files through text editor. This was obvioulsy going to be faster than using vnc or any other kind of remote desktop protocol.

This worked fine for small assignments but slowed down for projects with a lot of files. I was working on a react project and indexing all modules became a big task. This also meant you needed to install all basic language tools locally and remote server served as nothing more than a network drive.

During this mess of a workflow I also learnt about direnv, a tool to set environment variables specific to each project directory. You should check it out if you haven't already.

A better workflow

Second logical workflow involved using exclusively just the terminal and ssh into the remote server.
Just cloning the repo and installing stuff wasn't going to cut it. Every time I needed to work I had to ssh into machine and navigate to that repo then open a file to edit it. Working on multiple files by opening multiple terminal windows was a nightmare.

Now came TMUX, like a savior from the dark. It was just the solution I needed and more. Honestly anyone who has used tmux knows how awesome it is and I recommend it to everyone to try it out. It is used to create multiple terminals inside a single console window. Taking terminator and applying it inside a console instead of using it on a gui.

TMUX
Image from tecmint, check out their tmux article for deeper look.

TMUX starts a session and each session contains some windows and each window can be divided into multiple panes. TMUX session don't need to be closed whenever you close a terminal window they can be suspended to background.
This meant I don't even need to start a new session every time I need to work, all I need to do is create a session after I am done cloning the repo. Now whenever I ssh I could just open that session and start working on my project.
This solved a lot of problems, I didn't have to write any script to start a session and my environment was always ready whenever I wanted to start working.

Downsides

There are obviously a lot of downsides to this approach.

  1. You loose any support for gui editors and are locked with terminal editors like vim and emacs.
  2. Some workflows are straight up impossible to shift to cloud like developing GUI apps or working with external devices. These will require a lot of extra setup and might not be optimized and won't be as portable.

Have you tried any interesting workflows you might want to discuss about in the comment section?

Top comments (7)

Collapse
 
jillesvangurp profile image
Jilles van Gurp

You might want to try mosh. This adds a lot of convenience to ssh and allows you to deal with networking issues. Mosh basically uses udp and can keep the session alive as you roam between networks, go on and offline. This is great if you have a laptop. Additionally, it provides a bit better latency and you edit on a local buffer that is synchronized asynchronously. So, you are never blocked on network latency with your key presses. A few years ago when I was working out of coffee shops with generally not great networking, this was a great enabler.

Another thing you could consider is that instead of getting a really big vm on the off chance that you need to do some cpu intensive stuff once in a while, you can just spin up temporary instances and gather the results. Spinning up a huge vm can be expensive but if it only runs for a few minutes the cost becomes quite reasonable. In Amzaon you would do this using spot instances and do some scripting to spin those up and down using aws cli. I'm sure digital ocean has similar stuff. Mostly when doing command line stuff in a terminal you don't actually need a lot of hardware but it is nice to be able to spin it up on demand.

Collapse
 
zeerorg profile image
Rishabh Gupta

As a matter of fact I did try mosh, but found it slow compared to ssh on a reliable network. Will try to go for another type of vm, since tmux sessions sit in RAM they don't eat up a lot of cpu, but buiding huge projects while working do take up cpu cycles in burst, this workload can benefit from a different type of VM.

Collapse
 
basitali profile image
Basit Ali Mundia

Cloud9 IDE made for the lack of GUI editors. I remember Eclipse Che providing a similar experience. Only if we could get a vscode for the cloud.

Collapse
 
zeerorg profile image
Rishabh Gupta

Eclipse che takes up a lot of performance and runs poorly on a browser. Also, vscode for cloud is something that I need too.

Collapse
 
basitali profile image
Basit Ali Mundia

True, something like codesandbox would kill it.

Collapse
 
edh_developer profile image
edh_developer

This sounds like GNU Screen, which is cool when you don't want to rely on the presence of a window manager.

Regarding GUI editors, have you looked at Eclipse Orion?

Collapse
 
zeerorg profile image
Rishabh Gupta • Edited

I tried to install eclipse che on a personal vm, but found it slow. Coupled with the fact that there was no authentication by default literally anyone with the link to my vm could login, I had to choose another workflow.

GNU screen is an old project that is not in maintenance anymore, that is the reason I went with TMUX. it also has great shortcut support.