<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ben Potter</title>
    <description>The latest articles on DEV Community by Ben Potter (@bpmct).</description>
    <link>https://dev.to/bpmct</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F68740%2Fd8256ab7-8a8f-4383-8726-a7b9d22e4820.jpg</url>
      <title>DEV Community: Ben Potter</title>
      <link>https://dev.to/bpmct</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bpmct"/>
    <language>en</language>
    <item>
      <title>Achieving low latency remote development</title>
      <dc:creator>Ben Potter</dc:creator>
      <pubDate>Mon, 14 Mar 2022 13:17:21 +0000</pubDate>
      <link>https://dev.to/bpmct/achieving-low-latency-remote-development-34lj</link>
      <guid>https://dev.to/bpmct/achieving-low-latency-remote-development-34lj</guid>
      <description>&lt;p&gt;Remote IDEs bring speed and productivity benefits to software teams. Server-class machines lead to faster performance and reduced cycle time between changing code and seeing the result. For developers, this means faster &lt;a href="https://coder.com/blog/automate-developer-onboarding-with-coder"&gt;onboarding&lt;/a&gt; and less time troubleshooting environments.&lt;/p&gt;

&lt;p&gt;However, it’s important to make remote IDEs feel as fast, if not faster, than local machines. In this post, we’ll cover &lt;strong&gt;latency&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Latency hinders flow
&lt;/h2&gt;

&lt;p&gt;As demonstrated by a &lt;a href="https://input-delay.glitch.me/"&gt;typing latency simulator&lt;/a&gt;, delays immediately impact your productivity. Even with powerful servers, a reliable connection is just as important.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DbUiAi-b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gl8r9dtspyqmi8b912x7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DbUiAi-b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gl8r9dtspyqmi8b912x7.gif" alt="Typing latency demonstration" width="600" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this post, we’ll refer to “latency” as the connection delay between the developer (client) and workspace (server), and not operations inside the workplace itself (compiles, builds, tests) as those are unaffected by the user’s internet speed.&lt;/p&gt;

&lt;p&gt;Let’s take a look at how we can tune remote workspaces to have the “snappy” experience we know and love. &lt;/p&gt;

&lt;h2&gt;
  
  
  Optimize your infrastructure
&lt;/h2&gt;

&lt;p&gt;First, we recommend using servers &lt;strong&gt;close in proximity to your developers&lt;/strong&gt;! 🌎&lt;/p&gt;

&lt;p&gt;At Coder, we have a distributed engineering team. Our developers can pick between servers in the United States, United Kingdom, Spain, Australia for the optimal experience. If engineers join from another location, we can quickly deploy another &lt;a href="https://coder.com/docs/coder/latest/admin/workspace-providers"&gt;workspace provider&lt;/a&gt; in that region to support them. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h43yVeoz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kyot5tkaw1byci3kzmyb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h43yVeoz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kyot5tkaw1byci3kzmyb.png" alt="Distributed map" width="880" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are using a managed development platform, this is not something you can control. If geolocation and network speeds are important to you, self-hosting with your workspaces is advised. You can use software such as &lt;a href="https://coder.com/docs"&gt;Coder&lt;/a&gt;, &lt;a href="https://www.gitpod.io/self-hosted"&gt;Gitpod&lt;/a&gt;, or a homegrown solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use remote IDEs, when possible
&lt;/h2&gt;

&lt;p&gt;If you’re developing through a virtual desktop solution (e.g VDI, RDP, VNC), the overhead from streaming an entire desktop environment will often result in additional latency.&lt;/p&gt;

&lt;p&gt;Whenever possible, we recommend using native IDEs (web-based or desktop). With VS Code and JetBrains &lt;a href="https://coder.com/docs/coder/latest/workspaces/editors"&gt;remote development extensions&lt;/a&gt;, you can develop directly on remote workspaces with low latency.&lt;/p&gt;

&lt;p&gt;If you still need to access desktop-only apps, you can still use your virtual desktop to complement your IDE, potentially all &lt;a href="https://coder.com/blog/run-any-application-or-ide-in-coder"&gt;through the same workspace&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nt6kV_Tu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g30lsehlqsf40qcn0qz0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nt6kV_Tu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g30lsehlqsf40qcn0qz0.png" alt="VNC with VS Code" width="880" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you need fast remote desktop access, &lt;a href="https://parsec.app/"&gt;Parsec&lt;/a&gt; is an emerging tool to keep an eye on. At the time of writing, it only supports Windows and macOS hosts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use direct connections, whenever possible
&lt;/h2&gt;

&lt;p&gt;Reducing proxies and network hops provides users a snappier and more reliable experience, which is why we went through the effort of &lt;a href="https://coder.com/blog/rearchitecting-coder-networking-with-webrtc"&gt;implementing a peer-to-peer network architecture&lt;/a&gt; in Coder. As a result, we have achieved a 68% latency reduction, as measured by our &lt;a href="https://github.com/coder/coder-cli/blob/main/docs/coder_workspaces_ping.md"&gt;workspace ping utility&lt;/a&gt; (61.23ms to 29.92ms) for our internal developer workspaces.&lt;/p&gt;

&lt;p&gt;While your own performance improvement may vary depending on your network topology, in general, reducing the number of network hops and the physical distance between your computer and the server will reduce your perceptible latency.&lt;/p&gt;

&lt;h2&gt;
  
  
  Improving SSH responsiveness
&lt;/h2&gt;

&lt;p&gt;For those who prefer to use vim/terminals development, &lt;a href="https://mosh.org/"&gt;mosh&lt;/a&gt; is a great tool for reducing perceived latency in SSH connections.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n6BmewBl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/84jzxqfjr9eyiyqgp4yl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n6BmewBl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/84jzxqfjr9eyiyqgp4yl.png" alt="Mosh landing page" width="880" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mosh particularly comes in handy if you are on a limited internet connection, or if you’re far away from the data center.&lt;/p&gt;

&lt;h2&gt;
  
  
  What about offline mode?
&lt;/h2&gt;

&lt;p&gt;You may find yourself in cases where you’d like to access your workspace without a stable internet connection, such as on an airplane. &lt;/p&gt;

&lt;p&gt;We plan to cover this in a dedicated blog post, but our general recommendation is to define your remote workspaces with non-proprietary tools. With Dockerfiles, devcontainers, or standard VM images, you can optionally run your environments on local machines for an, albeit slower, offline development experience. Once an internet connection is restored, you can sync files back to your remote workspace.&lt;/p&gt;

&lt;h2&gt;
  
  
  Coder: self-hosted developer workspaces
&lt;/h2&gt;

&lt;p&gt;If you’re serious about moving software development to your infrastructure, we’d &lt;a href="https://coder.com/demo"&gt;love to chat&lt;/a&gt;. You can also &lt;a href="https://coder.com/docs/coder/latest/setup/docker#installing-coder-for-docker"&gt;install Coder&lt;/a&gt; for free and try it yourself.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>vscode</category>
      <category>jetbrains</category>
    </item>
    <item>
      <title>Faster JetBrains IDEs with shared indexes</title>
      <dc:creator>Ben Potter</dc:creator>
      <pubDate>Sun, 02 Jan 2022 21:53:11 +0000</pubDate>
      <link>https://dev.to/coder/faster-jetbrains-ides-with-shared-indexes-10n1</link>
      <guid>https://dev.to/coder/faster-jetbrains-ides-with-shared-indexes-10n1</guid>
      <description>&lt;p&gt;If you develop with IntelliJ IDEA, PyCharm, GoLand, or other JetBrains IDEs,  it’s likely you’ve waited for “indexing” to complete after opening a project. While this may be annoying, it’s necessary for IntelliJ and other heavy-weight IDEs to have features such as code search, highlighting, refactoring, and code completion.&lt;/p&gt;

&lt;p&gt;Waiting for an IDE to finish indexing a project might not be a big problem for many workflows. After the first load, indexes are cached and subsequent runs are faster. However, indexing time can be a huge blocker for developers, especially in these cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;large projects (monorepos, many dependencies, monolithic applications)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;running old/slow machines (indexing is CPU-intensive)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ephemeral developer workspaces (containers, remote IDEs)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksoux60kx7ntmfu4fywr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksoux60kx7ntmfu4fywr.png" alt="edit of xkcd's "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this post, we’ll cover how &lt;a href="https://www.jetbrains.com/help/idea/shared-indexes.html" rel="noopener noreferrer"&gt;shared indexes&lt;/a&gt; can significantly reduce IDE load times, share some examples, and a one-line command to generate these for your project. (Historically, shared indexes have been difficult to set up)&lt;/p&gt;

&lt;h2&gt;
  
  
  First, how indexing works
&lt;/h2&gt;

&lt;p&gt;Indexing works by traversing the project’s codebase to create a “virtual map” of classes, methods, and objects for future lookups. After the index is generated, it is cached on your device for later use.&lt;/p&gt;

&lt;p&gt;Indexing a codebase will likely take the longest &lt;strong&gt;the first time you open it on your machine&lt;/strong&gt;. When the codebase changes, such as pulling code or switching branches, your indexes will “update,” but significantly faster than the first time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shared indexes ⚡
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.jetbrains.com/help/idea/shared-indexes.html" rel="noopener noreferrer"&gt;Shared indexes&lt;/a&gt; make it possible to host pre-generated indexes for others to download, significantly improving loading speeds across your team. These remote indexes work in conjunction with local indexing to ensure your IDE always has up-to-date information on the codebase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.datocms-assets.com%2F19109%2F1639079914-final61b24be6b9a30400a127b80d760422.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.datocms-assets.com%2F19109%2F1639079914-final61b24be6b9a30400a127b80d760422.gif" alt="Comparison: local vs shared indexes"&gt;&lt;/a&gt;GIF: Loading the code-server project in WebStorm&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating shared indexes for your project
&lt;/h2&gt;

&lt;p&gt;JetBrains has a &lt;a href="https://www.jetbrains.com/help/idea/shared-indexes.html" rel="noopener noreferrer"&gt;guide for creating shared indexes&lt;/a&gt;, but it involves many steps, including downloading custom tooling and uploading indexes to a CDN. It also lacks instructions for automating this process, to generate indexes in CI, for example.&lt;/p&gt;

&lt;p&gt;Using a Docker container to generate shared indexes makes it simple to try locally or automate with cron/CI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;your_large_codebase/

&lt;span class="c"&gt;# generate shared indexes&lt;/span&gt;
docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;:/var/project &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;/indexes-output:/shared-index &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;INDEXES_CDN_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://cdn.myserver.com/project &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  bencdr/indexer:idea-2021.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After generating indexes, you can upload the output folder to your CDN, or a local server. You can also use shared indexes without a CDN by using a network share or even your local filesystem for testing. Check out my &lt;a href="https://github.com/bpmct/indexer" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt; for details:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/bpmct" rel="noopener noreferrer"&gt;
        bpmct
      &lt;/a&gt; / &lt;a href="https://github.com/bpmct/jetbrains-indexer" rel="noopener noreferrer"&gt;
        jetbrains-indexer
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Generate &amp;amp; package JetBrains shared indexes with a Docker container.
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;h2&gt;
  
  
  Benchmarking shared indexes
&lt;/h2&gt;

&lt;p&gt;I tested indexing time for some popular projects on my 2019 MacBook Pro. To benchmark your own projects, &lt;code&gt;File → Invalidate Caches&lt;/code&gt; in your IDE will allow you to opt in/out of downloading shared indexes to simulate first launching your project.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Project&lt;/th&gt;
&lt;th&gt;Language(s)&lt;/th&gt;
&lt;th&gt;Local indexing 🐌&lt;/th&gt;
&lt;th&gt;With shared indexes ⚡&lt;/th&gt;
&lt;th&gt;Improvement %&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/kubernetes/kubernetes" rel="noopener noreferrer"&gt;kubernetes/kubernetes&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;2m 40s&lt;/td&gt;
&lt;td&gt;22s&lt;/td&gt;
&lt;td&gt;727%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/cdr/code-server" rel="noopener noreferrer"&gt;cdr/code-server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Typescript&lt;/td&gt;
&lt;td&gt;2m 30s&lt;/td&gt;
&lt;td&gt;34s&lt;/td&gt;
&lt;td&gt;441%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Coder internal monorepo&lt;/td&gt;
&lt;td&gt;Go &amp;amp; Typescript&lt;/td&gt;
&lt;td&gt;3m 20s&lt;/td&gt;
&lt;td&gt;32s&lt;/td&gt;
&lt;td&gt;625%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/jetbrains-intellij-community" rel="noopener noreferrer"&gt;jetbrains/intellij-community&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Java&lt;/td&gt;
&lt;td&gt;6m 30s&lt;/td&gt;
&lt;td&gt;2m 15s&lt;/td&gt;
&lt;td&gt;288%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These times were averaged across two test runs. Your mileage will vary depending on network speeds, device performance, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Remote development &amp;amp; shared indexes
&lt;/h2&gt;

&lt;p&gt;Recently, JetBrains released &lt;a href="https://www.jetbrains.com/remote-development/" rel="noopener noreferrer"&gt;remote development support&lt;/a&gt;, making it simple to develop from powerful, remote workspaces. On-demand workspaces have a lot of benefits, such as faster onboarding and better reproducibility. However, first-time indexing happens much more frequently, since, after all, workspaces are meant to be ephemeral.&lt;/p&gt;

&lt;p&gt;Shared indexes work with &lt;a href="https://coder.com" rel="noopener noreferrer"&gt;Coder&lt;/a&gt;, our remote development platform. Coder supports all JetBrains IDEs locally, or via the web browser. If you don’t want to host a CDN for shared indexes, you can include them in the workspace image, so everything loads in a snap ⚡&lt;/p&gt;

&lt;p&gt;If you’d like to learn more about Coder, you can &lt;a href="https://coder.com/demo" rel="noopener noreferrer"&gt;request a demo&lt;/a&gt; or &lt;a href="https://coder.com/trial" rel="noopener noreferrer"&gt;try it for free&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=xJKff0QUd3c" rel="noopener noreferrer"&gt;Talk: Indexing, or How We Made Indexes Shared and Fast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.jetbrains.com/remote-development/" rel="noopener noreferrer"&gt;JetBrains Remote Development&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.jetbrains.com/help/idea/shared-indexes.html" rel="noopener noreferrer"&gt;JetBrains docs: Indexing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/damintsew/idea-shared-index-dockerfile" rel="noopener noreferrer"&gt;GitHub: idea-shared-index-dockerfile&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>productivity</category>
      <category>tooling</category>
      <category>performance</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
