A large cloud has thousands of resources. They must be created, joined and managed by software, not by hand. The newest step removes servers from the view of the developer altogether.
Provisioning and Orchestration
Provisioning is the creation and set-up of resources, such as VMs, networks and storage, for a user. Orchestration is the automatic coordination of many such tasks into a workflow, so that a whole application is built and run in the right order. Infrastructure as Code (IaC) describes the desired infrastructure in files, which are stored in version control and run by a tool. This makes set-up repeatable, fast and free from manual errors. Common tools are Terraform, which works with many providers, AWS CloudFormation and Azure Resource Manager, Ansible, Chef and Puppet, which configure software, OpenStack, an open-source cloud platform with services such as Nova for compute, Neutron for networks, Cinder for block storage, Swift for object storage and Horizon for the dashboard, and Kubernetes for containers.
Definition: Infrastructure as Code. The practice of describing and managing computing infrastructure in machine-readable files that are versioned and run by tools, instead of configuring it by hand.
Serverless Computing
In serverless computing, the developer writes code and the provider runs it, without the developer managing any servers. The servers still exist, but the provider handles provisioning, scaling and upkeep. The code runs in response to events, and the user pays only for the time that the code runs, often measured in milliseconds, and nothing when it is idle. Scaling is automatic, even to zero.
Function as a Service (FaaS)
FaaS is the main form of serverless. The developer writes small functions, each doing one job, such as resizing an image when it is uploaded. A function is started by an event, such as an HTTP request, a file upload, a timer or a message. Examples are AWS Lambda, Azure Functions and Google Cloud Functions. Advantages are no server management, automatic scaling and pay-per-use. Limits are the cold start, a delay when a function runs for the first time, time limits on each run, statelessness, so that data must be kept in an outside store, and the risk of vendor lock-in.
Table 2.5: Provisioning tools
| Tool | Type | Use |
|---|---|---|
| Terraform | Infrastructure as Code | Create resources on many clouds |
| Ansible | Configuration | Install and set up software |
| OpenStack | Cloud platform | Build a private cloud |
| Kubernetes | Container orchestration | Run containers at scale |
Example 2.5: Cost of a serverless function
Problem: A function runs 2 million times a month, 200 ms each time, with a price of Rs 0.0000015 per 100 ms and Rs 0.15 per 1,000 requests. Estimate the monthly cost.
Solution:
- Compute: 200 ms = 2 units of 100 ms. Units = 2,000,000 × 2 = 4,000,000. Cost = 4,000,000 × 0.0000015 = Rs 6.
- Requests: 2,000 thousand × 0.15 = Rs 300.
- Total = 6 + 300 = Rs 306.
Result: The cost is about Rs 306 a month, and nothing for the months in which it is not used.
runs = 2_000_000
compute = runs * 2 * 0.0000015
requests = runs / 1000 * 0.15
total = compute + requests
print(round(compute, 2), round(requests, 2), round(total, 2))
Output
6.0 300.0 306.0
Common mistakes
- Thinking that serverless means that there are no servers. The provider manages them.
- Keeping state in a function, which is lost after the run.
- Using serverless for long, steady jobs, where a server may cost less.
Key takeaways
- Orchestration automates many tasks into a workflow.
- Infrastructure as Code describes infrastructure in versioned files.
- Serverless runs code on events and charges only for run time.
- FaaS functions are stateless and may have a cold start.
Practice questions
- What is Infrastructure as Code?
- What is serverless computing?
- What is a cold start?
Answers to the practice questions
- Describing and managing infrastructure in versioned, machine-readable files run by tools.
- A model in which the provider runs the developer's code and manages all servers, charging only for use.
- The delay when a function runs for the first time and the environment must be created.
Sources
- Official BCA syllabus Cloud Computing, course code 25BCA405DS03, Unit II
