Introducing Nx Cloud 2.0
Tags: nrwl, nx, monorepo, cloud
Published: 2021-06-09 16:27:28

Introducing Nx Cloud 2.0 -- a cloud companion for your Nx monorepo helping you ensure you're enabling your teams to work as efficiently as possible.

This new version of Nx Cloud provides:

- Faster local development using Zero-Config Distributed Caching
- Faster CI using Zero-Config Distributed Task Execution
- GitHub integration for glanceable information
- Insights into measuring your development workflow over time.

{% youtube GT7XIwG1i5A %}

---

## Distributed Task Execution

![Distributed Task Execution](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5v7g1xnw3pnqnkv4ud4.png)

When working in large codebases, running tasks based on what is affected is a significant time-saver. However, there are some scenarios where you do need to run many tasks based on changes to the source code. There is a natural progression to this process. You start with running tasks locally on your individual machine. When that becomes a bottleneck, you run tasks in parallel locally. When you have a large Continuous Integration(CI) pipeline, it becomes much more efficient to distribute those tasks to run in parallel across multiple machines.

Traditionally, you might set up a parent job to split your tasks such as linting and testing into “buckets” and use child jobs to run each bucket of tasks, each with its own task details. Even in basic cases, like running tests, this turns into a challenging and ongoing effort and is simply not possible for cases where tasks depend on each other such as executing builds.

Nx Cloud solves this problem with Distributed Task Execution. DTE provides a Zero-Config️ integration with Nx Cloud that coordinates and schedules all the tasks created through Nx, executes them across multiple machines, and collects the results from these tasks into a single run.

You get a clean, consolidated view of all tasks run and their details in your Nx Cloud run details. Scaling up your CI infrastructure to parallelize even more tasks becomes as simple as adding more agents to listen for tasks.

--- 

## Distributed Caching 

![Nx Distributed Caching](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65aberan9j1rcmd3ic6r.png)

Working efficiently inside a monorepo involves minimizing the amount of code you write and run, along with maximizing the amount of code that you share. When there are multiple groups of developers working inside the same space, they tend to run the same tasks repeatedly against the same set of files. Nx is smart in that it detects which projects were affected by a given change, and only runs the necessary tasks for those changes, such as building, testing, and linting. 

Nx also caches the results on these tasks based on the source code and the context. This saves time and gives developers the ability to work faster towards shipping features, knowing that they don’t have to spend time waiting on all possible tasks to complete. 

Nx Cloud builds on top of this feature and provides a low-configuration, global cache available to everyone in your organization. With Nx Cloud, the same cached commands and artifacts available to developers locally, is pushed up to Nx Cloud, so when developers finish their changes, open a pull request and push them to run in the Continuous Integration pipeline, the cache is already populated, decreasing CI time as those tasks don’t have to be re-run. This saves time, and scales across your entire organization, allowing your developers to verify and ship features quicker.

---

## GitHub Integration

![Nx Cloud GitHub Integration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gjw770io63z4hk7ruouf.png)

CI environments are a necessity to keep the development pipeline flowing, but are not the best place to dig for information when your pull request tasks are complete. It usually involves clicking a link that takes you to a minimalistic page with lots of text to scroll through. When you just want to see what tasks were run with Nx, along with the results of those projects, this can slow down your feedback loop. Nx Cloud provides integration with GitHub that connects your Nx Cloud information to your pull requests.

This integration gives you:

- Actionable result from each PR with its associated set of runs
- Quick links to jump to any particular task that succeeded or failed.
- Direct access to see commands and terminal outputs for each individual command without ever visiting your CI dashboard.

Visit the Nx Cloud GitHub integration page for more details: 

## Insights

![Nx Cloud Insights](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c47dd8lvay2p99mf3q9h.png)

Nx Cloud also gives you valuable insights about your workspace. Find out exactly how much time you’re saving with Nx Cloud using the Cache Stats graph. This can be used to measure your CI performance over time, and look for potential bottlenecks.

![Nx Cloud CI performance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3hxldu2bfjjsr9tqy1m.png)

View information about tasks using the run details view. Individual runs are displayed along with results, cache hits or misses, and associated terminal logs.

![Nx Cloud Run Details](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cd01r1qp0f7sl56xma5d.png)

---

## Getting Started

Getting started with Nx Cloud is as quick as connecting your existing Nx 12.x workspace to Nx Cloud.

```sh
nx connect-to-nx-cloud
```

> For Nx workspaces prior to version 12:

Installing with `yarn`

```sh
yarn add @nrwl/nx-cloud && yarn nx g @nrwl/nx-cloud:init
```

Installing with `npm`

```sh
npm install @nrwl/nx-cloud && npx nx g @nrwl/nx-cloud:init
```

Next, click the provided link to connect your workspace to Nx Cloud.

This gives you a fully hosted/managed Nx Cloud organization to use. View your run details, cache stats, and other information without additional infrastructure.

We also have [Nx Private Cloud](https://nx.app/private-cloud) that can be deployed internally within our organization with the same assurances and security of the hosted/managed Nx Cloud provided by Nrwl.

Visit [nx.app](https://nx.app) to learn more about Nx Cloud and how it can enhance your usage of Nx.