236
F. Firouzi and B. Farahani
Fig. 4.38 High-level architecture as well as the programming model of OpenWhisk
a rule is a loosely coupled association between a trigger and an action. Behind the
scene, OpenWhisk is implemented based on the following main building blocks:
• Nginx: Nginx is an open-source HTTP and reverse proxy server.
• Controller: Controller is an implementation of the actual REST API and Nginx
forward all the HTTP requests to the controller which functions as the gatekeeper
of the OpenWhisk. As its name suggests, the controller performs the authentication and authorization and finally decides the path that the request will eventually
take. It should be noted that the controller is written in Scala programming
language.
• Redis: Nginx can be optionally connected to Redis for caching.
• CouchDB: CouchDB is a document-oriented NoSQL database which stores the
state of the system, credentials (for authentication and authorization), metadata,
namespaces, and the definitions of actions, triggers, and rules.
• Consul: Consul is a tool that acts as a service registry and discovery in the system.
• Kafka: Kafka is a fault-tolerant distributed message broker which buffers and
delivers the messages sent by the controller to invokers.
• Invoker: Invoker, which is written in Scala, is the component that is responsible
for receiving invocation request from the controller via Kafka, spinning up a
container, and executing the corresponding action. In OpenWhisk, containers are
managed using Docker technology. Docker is the most well-known framework
designed to make it easier to create, deploy, and run containers. When the
execution of an action function is done, the invoker stores the corresponding
results in CouchDB. It should be noted that inside each container, OpenWhisk
puts a light HTTP server with two endpoints, namely, /init and /run. The /init
endpoint is responsible for taking the action’s code, preparing the code for
execution, and the initialization of the container. For example, it might be
necessary to compile the code to be ready for the execution. The /run endpoint
triggers the execution of the action code. Note that the initialization of a container
Précédent

- 243/647

Suivant