Infrastructure
Globe is built on top of multiple cloud compute providers to provide a scalable and reliable service. The following sections provide an overview of the infrastructure used to run Globe & how you can integrate your Dart applications.
How it works
Each time you create a new successful deployment, the Globe deployment service creates an executable of your Dart project. This executable is distributed to our global private deployment registry.
When a user makes a request to your application, they first end up connecting to our global edge network (300+ locations). Our edge network provides zero latency routing management and allows us to route your user to the nearest Globe compute region where our infrastructure will start a container in isolation on demand if necessary.
Our edge network routing service is also responsible for features such as DDoS mitigation, instant rollbacks, A/B testing deployments and more.
Containers
Globe uses container technology to start your Dart applications on demand. The platform will automatically scale your application based on the number of requests it receives. Containers are created on demand in the closest region to where a user request originates from.
An on demand container environment means you should:
- Not rely on having a persistent file system.
- Not rely on having persistent memory.
Even if a user is performing multiple requests from the same region, it is not guaranteed that the same container will be used to handle the request. Treat each request as though it is a new environment.
Serverless
Globe currently does not yet have a functions / serverless model, however we are experimenting providing this via upcoming technologies like WASM. Please consider providing your thoughts and your upvote on this feature request if this is something that interests you.
Starting a server
The Globe infrastructure expects that your Dart application starts listening to a port whenever executed. During the build phase of a deployment, a check will take place to ensure that your application is listening to a port. If this is not the case, the deployment will fail.
Using a package such as shelf, you can easily start a server which accepts in-bound HTTP requests by accessing
the PORT
environment variable:
import 'dart:io';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as shelf_io;
void main() async {
final handler =
const Pipeline().addHandler((Request request) {
return Response.ok('Hello, World!');
});
final server = await shelf_io.serve(
handler,
// Use any IPv4 address.
InternetAddress.anyIPv4,
// Use the PORT environment variable.
int.tryParse(Platform.environment['PORT'] ?? '8080') ?? 8080,
);
}
Limitations
Globe imposes a few request limits to ensure that the platform is not abused.
File System
You should only rely on the file system for temporary storage such as processing of files. Any files created during a request will be removed once the request is finished.
Execution Timeout
A single request is allowed to run for a maximum duration. If a request takes longer than the allowed duration, the request will be terminated.
During private preview the maximum duration is currently 5 seconds. We may increase this based on feedback and also allow higher limits for paid plans in future.
CPU Usage
You cannot perform CPU heavy tasks for an extended period of time (determined by the current infrastructure load). Any requests which exceed the allotted CPU usage will be terminated.
Memory Usage
Each container has a limited amount of memory available (128MB). Performing on-going memory heavy tasks may result in the request being terminated. We may increase this based on feedback and also allow higher limits for paid plans in future.
FFI
Usage of FFI (via dart:ffi
) is not currently supported. We are working on providing this in future.