Faasm: Lightweight Isolation for Efficient Stateful Serverless Computing [zotero-users-5466518-xg9mvxpy]
Simon Shillaker, Peter Pietzuch
1. Commentary
1. Commentary
2. Highlights
2. Highlights
2.1. Page 2 [zotero-users-5466518-n4l8xjtg]
2.1. Page 2 [zotero-users-5466518-n4l8xjtg]
Our run- time for Faaslets, FAASM, isolates other resources, e.g. CPU and network, using standard Linux cgroups, and provides a low-level POSIX host interface for networking, file system access and dynamic loading. To reduce initialisation times, FAASM restores Faaslets from already-initialised snapshots.
2.1.1. Commentary
2.1.1. Commentary
2.2. Page 2 [zotero-users-5466518-7vuagt6v]
2.2. Page 2 [zotero-users-5466518-7vuagt6v]
Containers have start-up latencies in the hundreds of milliseconds to several seconds, leading to the cold-start problem in today’s serverless platforms [36, 83].
2.2.1. Commentary
2.2.1. Commentary
2.3. Page 3 [zotero-users-5466518-rszczq9n]
2.3. Page 3 [zotero-users-5466518-rszczq9n]
Terrarium [28] and Cloudflare Workers [22] employ software-based isolation us- ing WebAssembly and V8 Isolates, respectively; Krustlet [54] replicates containers using WebAssembly for memory safety; and SEUSS [16] demonstrates serverless unikernels
2.3.1. Commentary
2.3.1. Commentary
2.4. Page 3 [zotero-users-5466518-lmcb674d]
2.4. Page 3 [zotero-users-5466518-lmcb674d]
Data should be co-located with functions and ac- cessed directly, minimising data-shipping.
2.4.1. Commentary
2.4.1. Commentary
2.5. Page 3 [zotero-users-5466518-uixpfh8s]
2.5. Page 3 [zotero-users-5466518-uixpfh8s]
Faaslets use a two-tier state architecture, a local tier provides in-memory sharing, and a global tier supports distributed access to state across hosts. The FAASM runtime provides a state management API to Faaslets that gives fine-grained control over state in both tiers
2.5.1. Commentary
2.5.1. Commentary
2.6. Page 3 [zotero-users-5466518-bsn25362]
2.6. Page 3 [zotero-users-5466518-bsn25362]
To reduce cold- start time when a Faaslet executes for the first time, it is launched from a suspended state. The FAASM run- time pre-initialises a Faaslet ahead-of-time and snapshots its memory to obtain a Proto-Faaslet, which can be re- stored in hundreds of microseconds.
2.6.1. Commentary
2.6.1. Commentary
2.7. Page 3 [zotero-users-5466518-uwt34wrm]
2.7. Page 3 [zotero-users-5466518-uwt34wrm]
The host interface provides just enough virtualisation to ensure isolation while adding a negligible overhead. The FAASM runtime1 uses the LLVM compiler toolchain to translate applications to WebAssembly and supports func- tions written in a range of programming languages, including C/C++, Python, Typescript and Javascrip
2.7.1. Commentary
2.7.1. Commentary
2.8. Page 5 [zotero-users-5466518-c5n2mi9p]
2.8. Page 5 [zotero-users-5466518-c5n2mi9p]
There is a proposal to add a form of syn- chronised shared memory to WebAssembly [85], but it is not well suited to sharing serverless state dynamically due to the required compile-time knowledge of all shared regions. It also lacks an associated programming model and provides only local memory synchronisation.
2.8.1. Commentary
2.8.1. Commentary
2.9. Page 6 [zotero-users-5466518-iyt5gnqv]
2.9. Page 6 [zotero-users-5466518-iyt5gnqv]
The host interface integrates with the serverless runtime through a message bus (see Fig. 1). The message bus is used by Faaslets to communicate with their parent process and each other, receive function calls, share work, invoke and await other functions, and to be told by their parent process when to spawn and terminate.
2.9.1. Commentary
2.9.1. Commentary
2.10. Page 7 [zotero-users-5466518-islw8sz5]
2.10. Page 7 [zotero-users-5466518-islw8sz5]
Dynamic linking. Some legacy applications and libraries re- quire support for dynamic linking, e.g. CPython dynamically links Python extensions. All dynamically loaded code must first be compiled to WebAssembly and undergo the same validation process as other user-defined code (§3.
2.10.1. Commentary
2.10.1. Commentary
2.11. Page 7 [zotero-users-5466518-7y8reij4]
2.11. Page 7 [zotero-users-5466518-7y8reij4]
Faaslets do this by adding the new concept of shared regions to the existing WebAssembly memory model [35]. Shared regions give functions concurrent access to disjoint segments of shared process memory, allow- ing them direct, low-latency access to shared data structures.
2.11.1. Commentary
2.11.1. Commentary
2.12. Page 7 [zotero-users-5466518-g9bkm9aw]
2.12. Page 7 [zotero-users-5466518-g9bkm9aw]
Faaslets allocate shared process memory through calls to mmap on the underlying host, passing MAP_SHARED and MAP_ANONYMOUS flags to create shared and private regions, re- spectively, and remap these regions with mremap
2.12.1. Commentary
2.12.1. Commentary
2.13. Page 8 [zotero-users-5466518-jcvhm7dz]
2.13. Page 8 [zotero-users-5466518-jcvhm7dz]
When Faaslets are deployed, the compilation phase to gen- erate the WebAssembly binary takes place on a user’s ma- chine. Since that is untrusted, the code generation phase begins by validating the WebAssembly binary, as defined in the WebAssembly specification [35
2.13.1. Commentary
2.13.1. Commentary
2.14. Page 8 [zotero-users-5466518-nzgyw5mf]
2.14. Page 8 [zotero-users-5466518-nzgyw5mf]
Faaslets write changes from the local to the global tier by performing a push, and read from the global to the local tier by performing a pull. DDOs may employ push and pull op- erations to produce variable consistency, such as delaying updates in an eventually-consistent list or set, and may lazily pull values only when they are accessed, such as in a dis- tributed dictionary. Certain DDOs are immutable, and hence avoid repeated synchronisation.
2.14.1. Commentary
2.14.1. Commentary
2.15. Page 9 [zotero-users-5466518-lfr3f9wc]
2.15. Page 9 [zotero-users-5466518-lfr3f9wc]
The authoritative state value for each key is held in the global tier, which is backed by a distributed key-value store (KVS) and accessible to all Faaslets in the cluster. Faaslets on a given host share a local tier, containing replicas of each state value currently mapped to Faaslets on that host
2.15.1. Commentary
2.15.1. Commentary
2.16. Page 9 [zotero-users-5466518-bwflf7yi]
2.16. Page 9 [zotero-users-5466518-bwflf7yi]
To achieve this without modifications to the underlying platform’s scheduler, FAASM uses a distributed shared state scheduler similar to Omega [71]. Function calls are sent round-robin to local schedulers, which execute the function locally if they are warm and have capacity, or share it with another warm host if one exists.
2.16.1. Commentary
2.16.1. Commentary
2.17. Page 10 [zotero-users-5466518-25ytgevh]
2.17. Page 10 [zotero-users-5466518-25ytgevh]
Proto-Faaslet snapshot includes a function’s stack, heap, function table, stack pointer and data, as defined in the We- bAssembly specification [35]. Since WebAssembly memory is represented by a contiguous byte array, containing the stack,heap and data, FAASM restores a snapshot into a new Faaslet using a copy-on-write memory mapping.
2.17.1. Commentary
2.17.1. Commentary
2.18. Page 11 [zotero-users-5466518-zkcuntld]
2.18. Page 11 [zotero-users-5466518-zkcuntld]
The increased network transfer, memory usage and du- ration in Knative is caused primarily by data shipping, e.g. loading data into containers.
2.18.1. Commentary
2.18.1. Commentary
2.19. Page 12 [zotero-users-5466518-zf7xwq6f]
2.19. Page 12 [zotero-users-5466518-zf7xwq6f]
To highlight the impact of this sharing, we include the proportional set size (PSS) and resident set size (RSS) memory consumption. Initiali- sation times and CPU cycles are measured across repeated executions of a no-op function.
2.19.1. Commentary
2.19.1. Commentary
2.20. Page 13 [zotero-users-5466518-ut7z6tlh]
2.20. Page 13 [zotero-users-5466518-ut7z6tlh]
GraalVM has recently added support for WebAssembly and could be adapted for Faaslets