Skip to content
Skitsanos edited this page Jan 22, 2023 · 16 revisions

Foxx Microservices

ArangoDB allows application developers to write their data access and domain logic as microservices running directly within the database with native access to in-memory data. The Foxx microservice framework makes it easy to extend ArangoDB’s own REST API with custom HTTP endpoints using modern JavaScript running on the same V8 engine you know from Node.js and the Google Chrome web browser.

Unlike traditional approaches to storing logic in the database (like stored procedures), these microservices can be written as regular structured JavaScript applications that can be easily distributed and version controlled. Depending on your project’s needs, Foxx can be used to build anything from optimized REST endpoints performing complex data access to entire standalone applications running directly inside the database.

Foxx services consist of JavaScript code running in the V8 JavaScript runtime embedded inside ArangoDB. Each service is mounted in each available V8 context (the number of contexts can be adjusted in the server configuration). Incoming requests are distributed across these contexts automatically.

If you’re coming from another JavaScript environment like Node.js this is similar to running multiple Node.js processes behind a load balancer: you should not rely on the server-side state (other than the database itself) between different requests as there is no way of making sure consecutive requests will be handled in the same context.

Because the JavaScript code runs inside the database, another difference is that all Foxx and ArangoDB APIs are purely synchronous and should be considered blocking. This is especially important for transactions, which in ArangoDB can execute arbitrary code but may have to lock entire collections (effectively preventing any data to be written) until the code has been completed.

Because Foxx services use the V8 JavaScript engine, the engine’s default memory limit of 512 MB is applied.

Foxx Builder

Foxx Builder is a tool that helps developers quickly and easily create data backends for their web applications. It simplifies the process of creating ArangoDB Foxx services, by providing a clear and intuitive folder structure, automated routing, and context extensions that make it easy to perform common tasks such as database queries, validation and more. Additionally, it makes use of familiar conventions used in popular frontend frameworks like Umijs and Next.js, making it easier for developers to get started and be productive quickly.

Clone this wiki locally