Compute@Edge is a computation platform capable of running custom binaries that you compile on your own systems and upload to Fastly. Security and portability is provided by compiling your code to WebAssembly, which we run at the edge using Lucet, an open-source WebAssembly runtime created by Fastly.
Fastly must enable a Compute@Edge feature flag on a new Fastly account. We associate that feature flag with the customer ID (CID) of your new account to help you isolate your production activities from those you test and experiment with.
- Create a new account by following the steps in our signup form.
- Log in to your new account and find your customer ID. This appears in the Company settings page within the Account section of the web interface.
- Provide your Fastly contact with your CID so they can enable the Compute@Edge feature flag for your account.
- If you wish, invite additional users to your new account. Remember, these users must not already be collaborators on another Fastly account.
Compute@Edge services use packages built on your computer using the Fastly CLI. To authenticate the Fastly CLI, you must create an API token for your account. Follow the steps for creating an API token, make sure it has
global scope, and make a note of the token. The token will only allow access to the account you are using for Compute@Edge, and not your normal Fastly account.
The Fastly CLI is available from a number of package registries.
- MacOS: Install from Homebrew:$ brew install fastly/tap/fastly
- Windows: Install from Scoop:$ scoop bucket add fastly-cli https://github.com/fastly/scoop-cli.git$ scoop install fastly
- Linux: Packages are available for Debian/Ubuntu, Fedora, CentOS, and SUSE, along with prebuilt binaries. Visit the GitHub repo to download the package for your distro and see installation instructions for your package manager.
Verify everything works by running fastly version. For example:
$ fastly versionFastly CLI version vX.Y.Z (abc0001)Built with go version go1.13.1 linux/amd64
The CLI will notify you if a new version is available. You can update it using the fastly update command.
The CLI interacts with Fastly via our API, authenticated using an API token. Configure the CLI to act on your behalf using the token you previously created. Choose one of the following options to give the CLI access to your API token:
- (Recommended) Run fastly configure and follow the interactive prompts. This will store your API token credential in a configuration file and remember it for subsequent commands.
- Include the token explicitly on each command you run using the
- Set a
For an overview of all available commands, run fastly with no arguments. Succinct help about any command or subcommand is available via the
--help flag (e.g., fastly service -h). For verbose help, use the help command (e.g., fastly help service).
Fastly supports client SDKs for several languages that can compile to Compute@Edge compatible Wasm packages. Choose a language below to view language-specific guidelines for using its SDK.
Beta SDKs are not intended for production use and may change extensively as we iterate on customer feedback. We provide customers who participate in our Beta program the opportunity to test, validate, and provide feedback on future functionality. In Limited Availability, an SDK is suitable for production use with a limited number of customers. Reference documentation is complete but supporting tutorials and code examples may be lacking. In General Availability, an SDK is available for everyone to use, and is supported by extensive up to date references, examples, and tutorials.
While we recommend the use of official Fastly SDKs, you can also create your own for a language of your choice, or use a community-created SDK. Learn more about custom SDKs
To build your project, the Fastly CLI requires your local toolchain to be available and up to date. To install the toolchain for your chosen language, follow these instructions:
Compiling Rust applications for Compute@Edge requires Rust 1.49.0 and the wasm32-wasi toolchain. Install Rust and its dependencies so you can begin building Compute@Edge services:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.49.0
If you already have
$ rustup toolchain add 1.49.0
wasm32-wasi target for the 1.49.0 toolchain:
$ rustup target add wasm32-wasi --toolchain 1.49.0
Use the CLI setup wizard to provision a new Fastly service with the type of "wasm" (it’s the default type, so you don’t need to specify it). By default, the CLI will generate source code for your project in the current working directory.
To get you started, Fastly provides a library of Compute@Edge applications that are ready to compile and run on your service, so you can start from a working example that is as close as possible to the solution you are trying to achieve.
Right now, we offer the following starter kits:
- Beacon termination
- Default starter for AssemblyScript
- Default starter for Rust
- Static content
When you initialize a Compute@Edge project with fastly compute init, you'll be prompted to choose one of these starter kits.
Start the setup wizard:
$ fastly compute init
The system will display a series of prompts with which you can specify details about your service.
At the prompts, provide details about the service you're creating:
- Name: Enter a name for your service. By default, the CLI will use the name of the current directory.
- Description: Enter a short description for your service, or leave it blank.
- Author: The CLI will offer to use the email address of the user associated with your API token, but you can provide a different email address as the author of the service package if desired.
- Language: Select the toolchain you wish to use to build your service.
- Starter kit: Choose from the available starter kits or press enter to accept the default. You may also enter the URL of a GitHub repo to use a template not in in the list.
The CLI will set up a local development environment and a fastly.toml package manifest based on your selections, and provide some useful links and commands for working with your project:
Prior to CLI version 0.28.0 the init process prompted for the domain and backend, and created a live Fastly service in preparation for your first deployment. This has now been moved to the deploy process.
✓ Initializing...✓ Fetching package template...✓ Updating package manifest...✓ Initializing package...Initialized package example to:/DIR/SERVICE_AUTHOR/exampleTo publish the package (build and deploy), run:fastly compute publishTo learn about deploying Compute@Edge projects using third-party orchestration tools, visit:https://developer.fastly.com/learning/integrations/orchestration/SUCCESS: Initialized package example
By default fastly compute init will create your project in the current directory. To specify a different one, use the --path flag, but remember to change to the target directory before executing any other fastly commands that you want to run in the context of the new project.
After editing the source code, you'll compile it into a WebAssembly module that can be packaged for Fastly use. The Fastly CLI internally runs your language's compiler and generates the necessary WebAssembly binary.
$ fastly compute build
A successful build looks like this:
$ fastly compute build✓ Initializing...✓ Verifying package manifest...✓ Verifying local <selected language> toolchain...✓ Building package using <selected language> toolchain...✓ Creating package archive...SUCCESS: Built <selected language> package <name> (pkg/<name>.tar.gz)
During the limited availability phase of Compute@Edge, we require that your toolchain is up to date to build a package, so you may see a warning if you need to update before you can build.
Once you’re happy with your code and want to deploy the project to Fastly, run fastly compute deploy.
You will need a live Fastly service running on our Compute@Edge platform to which your package will be deployed. If you have one you want to use, you can add the service ID into the
service_id property in your fastly.toml before running the deploy command, but if not, we'll create a service for you automatically.
At the prompts, provide details about the service you're creating:
- Domain: Press enter to accept the automatically generated domain name (we'll take care of the TLS and DNS and give you a working domain immediately) or enter the name of the domain you'd like to associate with your service. You can also accept the default now and add more domains to the service later if you prefer.
- Backend: If you want to configure an origin server for your service, enter a valid hostname, or an IPv4 or IPv6 address. Alternatively enter (or accept the default) "originless" to create a service with no origin server. Such services cannot forward requests to your servers, but they can respond to client requests with a response composed within your Compute@Edge package.
Currently, it is not possible for Fastly services to have no backend, so if you choose specify "originless", a backend with address
127.0.0.1 will be added to the service. This backend will not accept traffic and can be deleted if you add a real origin server later.
$ fastly compute deployThere is no Fastly service associated with this package. To connect to an existing serviceadd the Service ID to the fastly.toml file, otherwise follow the prompts to create aservice now.Press ^C at any time to quit.Domain: [random-funky-words.edgecompute.app]Backend (originless, hostname or IP address): [originless]✓ Initializing...✓ Reading package manifest...✓ Creating service...✓ Creating domain...✓ Creating backend...✓ Validating package...✓ Uploading package...✓ Activating version...Manage this service at:https://manage.fastly.com/configure/services/PS1Z4isxPaoZGVKVdv0eYView this service at:https://random-funky-words.edgecompute.appSUCCESS: Deployed package (service PS1Z4isxPaoZGVKVdv0eY, version 1)
The output includes a link to manage your service in the Fastly web interface. You can use this link to perform more complex configuration of the service, such as adding or removing domains, changing origin server settings, and setting up logging endpoints.
HINT: Many customers like using Terraform to manage Fastly service configurations. If you want to do this, consider using Terraform to provision the service, and then add the
service_id to the fastly.toml file.
After the command completes, it may take up to an additional 20 seconds before the package begins handling requests, and any previous version of the package may continue to handle requests for up to a minute (there will be no previous version on your first deploy).
Open a browser or use a command line HTTP client such as cURL to issue a request to the domain that you assigned to the service.
$ curl -si "https://random-funky-words.edgecompute.app/"HTTP/2 200content-type: text/html; charset=utf-8date: Fri, 07 May 2021 14:49:00 GMTcontent-length: 150<iframe src='https://developer.fastly.com/compute-welcome' style='border:0; position: absolute; top: 0; left: 0; width: 100%; height: 100%'></iframe>
Or if you prefer, test it in a web browser:
Now that you have a working project deployed, you have the basic building blocks in place to be successful with Compute@Edge.
If you are already familiar with VCL and want to migrate an existing VCL configuration to Compute@Edge, try the VCL to Compute@Edge migration guide, which shows examples of the most common use cases in VCL and how to implement the same functionality using Compute@Edge's supported languages.
As an early customer, your feedback is invaluable to us and will help shape the future of Compute@Edge. We'd really appreciate any and all feedback on your experience, but especially any experiences related to:
- problems you had with the onboarding process.
- problems you had with the tools: the Fastly CLI or our Rust crates.
- problems you have with the programming model or the architecture of your application
- things that you haven’t been able to do, especially those you were expecting to but couldn’t.
Please be aware that not all features available within VCL services are yet available in Compute@Edge.
If you aren't sure where to provide feedback, your Fastly account contact can help or you can contact email@example.com.
- Create a new Fastly account and invite your collaborators
- Generate an API token
- Download and install the Fastly CLI
- Configure the Fastly CLI
- Choose a language to use
- Install local dependencies
- Create a new Compute@Edge project
- Compile the project to a Wasm binary
- Deploy the project to a new Fastly service
- Test and celebrate
- Next steps