Visit nuclio.io for product information and news and a friendly web presentation of the Nuclio documentation.
- Overview
- Why another "serverless" project?
- Quick-start steps
- High-level architecture
- Function examples
- Further reading
Nuclio is a new "serverless" project, derived from Iguazio's elastic data life-cycle management service for high-performance events and data processing. You can use Nuclio as a standalone Docker container or on top of an existing Kubernetes cluster. See deployment instructions in the Nuclio documentation.
Nuclio is extremely fast. A single function instance can process hundreds of thousands of HTTP requests or data records per second. This is 10-100 times faster than some other frameworks. To learn more about how Nuclio works, see the Nuclio architecture documentation, go over a recent presentation or watch Nuclio Serverless and AI webinar. Additional articles and tutorials are listed in Nuclio web site.
For further questions and support, click to join the Nuclio Slack workspace.
We considered existing cloud and open-source serverless solutions, but none addressed our needs:
- Real-time processing with minimal CPU and I/O overhead and maximum parallelism
- Native integration with a large variety of data sources, triggers, and processing models
- Abstraction of data resources from the function code - to support code portability, simplicity and data-path acceleration
- Simple debugging, regression testing, and multi-versioned CI/CD pipelines
- Portability across low-power devices, laptops, on-prem clusters and public clouds
We designed Nuclio to be extendable, using a modular and layered approach that supports constant addition of triggers and data sources. We hope many will join us in developing new modules, developer tools, and platforms.
The simplest way to explore Nuclio is to run its graphical user interface (GUI) of the Nuclio dashboard. All you need in order to run the dashboard is Docker:
docker run -p 8070:8070 -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp nuclio/dashboard:stable-amd64
Browse to http://localhost:8070, create a project, and add a function. When run outside of an orchestration platform (for example, Kubernetes or Swarm), the dashboard will simply deploy to the local Docker daemon.
Assuming you are running Nuclio with Docker, as an example, create a project and deploy the pre-existing template "dates (nodejs)".
With docker ps
, you should see that the function was deployed in its own container. You can then invoke your function with curl; (check that the port number is correct by using docker ps
or the Nuclio dashboard):
curl -X POST -H "Content-Type: application/text" -d '{"value":2,"unit":"hours"}' http://localhost:37975
For a complete step-by-step guide to using Nuclio over Kubernetes, either with the dashboard UI or the Nuclio command-line interface (nuctl
), see Getting Started with Nuclio on Kubernetes, Getting Started with Nuclio on Google Kubernetes Engine (GKE), or Getting started with Nuclio on Azure Container Services (AKS).
The following image illustrates Nuclio's high-level architecture:
Following is an outline of the main architecture components. For more information about the Nuclio architecture, see Architecture.
A processor listens on one or more triggers (for example, HTTP, Message Queue, or Stream), and executes user functions with one or more parallel workers.
The workers use language-specific runtimes to execute the function (via native calls, shared memory, or shell). Processors use abstract interfaces to integrate with platform facilities for logging, monitoring and configuration, allowing for greater portability and extensibility (such as logging to a screen, file, or log stream).
A controller accepts function and event-source specifications, invokes builders and processors through an orchestration platform (such as Kubernetes), and manages function elasticity, life cycle, and versions.
The dashboard is a standalone microservice that is accessed through HTTP and includes a code-editor GUI for editing, deploying, and testing functions. This is the most user-friendly way to work with Nuclio. The dashboard container comes packaged with a version of the Nuclio builder.
A builder receives raw code and optional build instructions and dependencies, and generates the function artifact - a binary file or a Docker container image that the builder can also push to a specified image repository. The builder can run in the context of the CLI or as a separate service, for automated development pipelines.
A dealer is used with streaming and batch jobs to distribute a set of tasks or data partitions/shards among the available function instances, and to guarantee that all tasks are completed successfully. For example, if a function reads from a message stream with 20 partitions, the dealer will guarantee that the partitions are distributed evenly across workers, taking into account the number of function instances and failures.
Functions can be invoked through a variety of event sources that are defined in the function (such as HTTP, RabbitMQ, Kafka, Kinesis, NATS, DynamoDB, Iguazio v3io, or schedule). Event sources are divided into several event classes (req/rep, async, stream, pooling), which define the sources' behavior. Different event sources can plug seamlessly into the same function without sacrificing performance, allowing for portability, code reuse, and flexibility.
Data-binding rules allow users to specify persistent input/output data resources to be used by the function. (Data connections are preserved between executions.) Bound data can be in the form of files, objects, records, messages, etc. The function specification may include an array of data-binding rules, each specifying the data resource and its credentials and usage parameters. Data-binding abstraction allows using the same function with different data sources of the same type, and enables function portability.
The Nuclio SDK is used by function developers to write, test, and submit their code, without the need for the entire Nuclio source tree.
The following sample function implementation uses the Event
and Context
interfaces to handle inputs and logs, returning a structured HTTP response; (it's also possible to use a simple string as the returned value).
In Go
package handler
import (
"github.com/nuclio/nuclio-sdk-go"
)
func Handler(context *nuclio.Context, event nuclio.Event) (interface{}, error) {
context.Logger.Info("Request received: %s", event.GetPath())
return nuclio.Response{
StatusCode: 200,
ContentType: "application/text",
Body: []byte("Response from handler"),
}, nil
}
In Python
def handler(context, event):
response_body = f'Got {event.method} to {event.path} with "{event.body}"'
# log with debug severity
context.logger.debug('This is a debug level message')
# just return a response instance
return context.Response(body=response_body,
headers=None,
content_type='text/plain',
status_code=201)
More examples can be found in the hack/examples Nuclio GitHub directory.
- Setup
- Getting Started with Nuclio on Minikube
- Getting Started with Nuclio on Kubernetes
- Getting Started with Nuclio on Azure Kubernetes Service (AKS)
- Getting Started with Nuclio on Google Kubernetes Engine (GKE)
- Getting Started with Nuclio on Raspberry Pi (coming soon)
- Tasks
- Concepts
- References
- Examples
- Roadmap
- Contributing
- Reference
- Media
For support and additional product information, join the active Nuclio Slack workspace.