CHAPTER 8Serverless Programming with Swift

In previous chapters of this book, you’ve read about Swift being used to implement cloud-hosted services that fit typical traditional server-side functions, such as web applications and data sources. However, there are some newer programming models that have arisen in cloud computing environments that offer distinct benefits for certain workloads. Swift also supports these models, and this chapter covers how the Swift language is used in one of these cloud environments—namely event-driven, or serverless, environments.

Microservices and Serverless Computing

An approach to cloud-native application architecture that has gained popularity and support in recent years involves multiple small, focused microservices being stitched together to form a full application. There are many advantages to structuring an application this way. Although a microservice-based architecture isn’t appropriate for every application, when it can be used, there are both economic and technical benefits to be exploited.

Because each microservice component of the overall application is independently deployable, it is easier to tune the application for maximum efficiency at scale than is the case for more monolithic application architectures. If one microservice is more resource intensive and requires more instances under heavy load than the others, then more instances of that one microservice can be deployed while the other microservices run fewer instances. In ...

Get Swift in the Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.