Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Simply Serverless

Annyce D.
January 16, 2020

Simply Serverless

Is your team using lambdas? Do you hear your backend developers talking about serverless applications? Curious to learn more? If so, this talk is for you. Effective serverless architectures require less backend code, less complexity, less risk, and less tech debt. But how is that possible? This talk aims to answer that question for you.

We'll cover:
* What is serverless
* When might you use it, and
* How can you develop a serverless app with Kotlin

Serverless application design is becoming more and more prevalent. Now is the time to understand this powerful shift in backend development, simply.

Annyce D.

January 16, 2020
Tweet

More Decks by Annyce D.

Other Decks in Programming

Transcript

  1. Simply Serverless
    Annyce Davis - @brwngrldev

    View full-size slide

  2. Lambda
    @brwngrldev

    View full-size slide

  3. Lambda
    @brwngrldev

    View full-size slide

  4. Lambda
    @brwngrldev
    • Launched by AWS in 2014

    View full-size slide

  5. Lambda
    @brwngrldev
    • Launched by AWS in 2014
    • Function as a Service (FaaS)

    View full-size slide

  6. Lambda
    @brwngrldev
    • Launched by AWS in 2014
    • Function as a Service (FaaS)
    • Typically event-driven (15 mins)

    View full-size slide

  7. Lambda
    @brwngrldev
    • Launched by AWS in 2014
    • Function as a Service (FaaS)
    • Typically event-driven (15 mins)
    • Multi-language support

    View full-size slide

  8. 1,430
    @brwngrldev

    View full-size slide

  9. Serverless
    @brwngrldev

    View full-size slide

  10. Serverless
    @brwngrldev

    View full-size slide

  11. Services
    @brwngrldev
    Area Type

    View full-size slide

  12. Services
    @brwngrldev
    Area Type
    Compute Functions (Lambda)

    View full-size slide

  13. Services
    @brwngrldev
    Area Type
    Compute Functions (Lambda)
    Storage Files, data (S3, DynamoDB)

    View full-size slide

  14. Services
    @brwngrldev
    Area Type
    Compute Functions (Lambda)
    Storage Files, data (S3, DynamoDB)
    Streaming Messages, queues (SNS, SQS)

    View full-size slide

  15. Services
    @brwngrldev
    Area Type
    Compute Functions (Lambda)
    Storage Files, data (S3, DynamoDB)
    Streaming Messages, queues (SNS, SQS)
    Querying ETL, SQL, ML (Rekognition)

    View full-size slide

  16. Serverless
    @brwngrldev

    View full-size slide

  17. Serverless
    @brwngrldev
    Code runs on air

    View full-size slide

  18. Serverless
    @brwngrldev
    Code runs on air

    View full-size slide

  19. Serverless
    @brwngrldev
    Code runs on air
    No servers to manage

    View full-size slide

  20. Code runs on air
    Serverless
    @brwngrldev
    Pay for what you use
    No servers to manage

    View full-size slide

  21. Code runs on air
    Serverless
    @brwngrldev
    Scalability provided by vendor
    Pay for what you use
    No servers to manage

    View full-size slide

  22. Landscape
    @brwngrldev
    On-premise Cloud native

    View full-size slide

  23. Landscape
    @brwngrldev
    On-premise Cloud native

    View full-size slide

  24. Players
    @brwngrldev

    View full-size slide

  25. Pros
    @brwngrldev

    View full-size slide

  26. Pros
    @brwngrldev
    • Faster time-to-market

    View full-size slide

  27. Pros
    @brwngrldev
    • Faster time-to-market
    • Cost savings

    View full-size slide

  28. Pros
    @brwngrldev
    • Faster time-to-market
    • Cost savings
    • Simplified scalability

    View full-size slide

  29. Pros
    @brwngrldev
    • Faster time-to-market
    • Cost savings
    • Simplified scalability
    • No specialized DevOps

    View full-size slide

  30. Pros
    @brwngrldev
    • Faster time-to-market
    • Cost savings
    • Simplified scalability
    • No specialized DevOps
    Cons

    View full-size slide

  31. Pros
    @brwngrldev
    • Faster time-to-market
    • Cost savings
    • Simplified scalability
    • No specialized DevOps
    Cons
    • Ecosystem immature

    View full-size slide

  32. Pros
    @brwngrldev
    • Faster time-to-market
    • Cost savings
    • Simplified scalability
    • No specialized DevOps
    Cons
    • Ecosystem immature
    • Vendor lock-in

    View full-size slide

  33. Pros
    @brwngrldev
    • Faster time-to-market
    • Cost savings
    • Simplified scalability
    • No specialized DevOps
    Cons
    • Ecosystem immature
    • Vendor lock-in
    • Multiple moving pieces

    View full-size slide

  34. Pros
    @brwngrldev
    • Faster time-to-market
    • Cost savings
    • Simplified scalability
    • No specialized DevOps
    Cons
    • Ecosystem immature
    • Vendor lock-in
    • Multiple moving pieces
    • Learning curve

    View full-size slide

  35. ServerLess
    @brwngrldev

    View full-size slide

  36. “Less”
    @brwngrldev

    View full-size slide

  37. “Less”
    @brwngrldev
    • Backend code

    View full-size slide

  38. “Less”
    @brwngrldev
    • Backend code
    • Complexity

    View full-size slide

  39. “Less”
    @brwngrldev
    • Backend code
    • Complexity
    • Risk

    View full-size slide

  40. “Less”
    @brwngrldev
    • Backend code
    • Complexity
    • Risk
    • Tech debt

    View full-size slide

  41. Getting
    Started
    @brwngrldev

    View full-size slide

  42. Demo
    @brwngrldev

    View full-size slide

  43. @brwngrldev
    http://serverlesscalc.com

    View full-size slide

  44. @brwngrldev
    Deploy
    Terraform

    View full-size slide

  45. resource "aws_api_gateway_method" "index_html" {
    depends_on = ["aws_api_gateway_resource.index_html"]
    rest_api_id = "${aws_api_gateway_rest_api.ufo_sightings.id}"
    resource_id = "${aws_api_gateway_resource.index_html.id}"
    http_method = "GET"
    authorization = "NONE"
    }
    resource "aws_api_gateway_resource" "graphql" {
    depends_on = ["aws_api_gateway_rest_api.ufo_sightings"]
    rest_api_id = "${aws_api_gateway_rest_api.ufo_sightings.id}"
    parent_id = "${aws_api_gateway_rest_api.ufo_sightings.root_resource_id}"
    path_part = "graphql"
    }
    resource "aws_cloudwatch_event_rule" "autowarm_merged_0" {
    name = "autowarm-merged-0"
    schedule_expression = "cron(0/5 * * * ? *)"
    }
    @brwngrldev
    Deploy
    Terraform

    View full-size slide

  46. @brwngrldev
    Deploy
    Terraform
    AWS
    CloudFormation
    Cloud
    Deployment
    Manager

    View full-size slide

  47. Serverless
    with Kotlin
    @brwngrldev

    View full-size slide

  48. @brwngrldev
    Ktor
    Koin
    Kotless

    View full-size slide

  49. @brwngrldev
    Ktor
    Application

    View full-size slide

  50. @brwngrldev
    Ktor
    Application
    Feature
    Feature

    View full-size slide

  51. @brwngrldev
    Ktor
    Application
    Feature
    Feature
    Routes

    View full-size slide

  52. @brwngrldev
    get("/") {
    }
    post("/graphql") {
    }
    Ktor

    View full-size slide

  53. @brwngrldev
    get("/") {
    call.respondRedirect("index.html")
    }
    post("/graphql") {
    }
    Ktor

    View full-size slide

  54. @brwngrldev
    get("/") {
    call.respondRedirect("index.html")
    }
    post("/graphql") {
    val request = call.receive()

    call.respondText(result)
    }
    Ktor

    View full-size slide

  55. @brwngrldev
    Koin
    val mainModule = module {
    single { Gson() }
    single { AppSchema(get()) }
    single { UFOSightingDatabase() }
    }

    View full-size slide

  56. @brwngrldev
    Koin
    val mainModule = module {
    single { Gson() }
    single { AppSchema(get()) }
    single { UFOSightingDatabase() }
    }
    val appSchema: AppSchema by inject()
    val gson: Gson by inject()

    View full-size slide

  57. @brwngrldev
    Kotless

    View full-size slide

  58. @brwngrldev
    Kotless
    1. Downloads Terraform

    View full-size slide

  59. @brwngrldev
    Kotless
    1. Downloads Terraform
    2. Generates deployment code

    View full-size slide

  60. @brwngrldev
    Kotless
    1. Downloads Terraform
    2. Generates deployment code
    3. Packs the lambda

    View full-size slide

  61. @brwngrldev
    Kotless
    1. Downloads Terraform
    2. Generates deployment code
    3. Packs the lambda
    4. Deploys the app to AWS

    View full-size slide

  62. @brwngrldev
    Ktor & Kotless
    class UFOSightingsApp : Kotless() {
    override fun prepare(app: Application) {
    with(app) {
    main()
    routes()
    }
    }
    }

    View full-size slide

  63. @brwngrldev
    kotless {
    config {
    }
    webapp {
    }
    }

    View full-size slide

  64. @brwngrldev
    kotless {
    config {
    bucket = "ktor-kotless-ufo.s3.adavis.info"
    dsl {
    type = DSLType.Ktor
    }
    terraform {
    profile = "default"
    region = "us-east-1"
    }
    }
    webapp {
    }
    }

    View full-size slide

  65. @brwngrldev
    kotless {
    config {
    bucket = "ktor-kotless-ufo.s3.adavis.info"
    dsl {
    type = DSLType.Ktor
    }
    terraform {
    profile = "default"
    region = "us-east-1"
    }
    }
    webapp {
    route53 = Route53("api", "ktor-kotless-ufo.info")
    }
    }

    View full-size slide

  66. @brwngrldev
    ./gradlew deploy

    View full-size slide

  67. Demo
    @brwngrldev

    View full-size slide

  68. https://github.com/adavis/ufo-sightings-api/tree/kotless
    @brwngrldev

    View full-size slide

  69. References
    @brwngrldev
    • Serverless Architectures (https://martinfowler.com/articles/serverless.html)
    • Kotless - Kotlin Serverless Framework (https://www.youtube.com/watch?v=69uk3Pi88AE)
    • AWS Serverless Resources (https://aws.amazon.com/serverless/resources)
    • 5 principles for cloud-native architecture (https://cloud.google.com/blog/products/application-
    development/5-principles-for-cloud-native-architecture-what-it-is-and-how-to-master-it)
    • GCP Solution Architectures (https://docs.google.com/presentation/d/
    1vjm5YdmOH5LrubFhHf1vlqW2O9Z2UqdWA8biN3e8K5U/edit#slide=id.p85)

    View full-size slide