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

Simply Serverless

Ce5b219b385d3e316a553d8a41900ed9?s=47 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.

Ce5b219b385d3e316a553d8a41900ed9?s=128

Annyce D.

January 16, 2020
Tweet

More Decks by Annyce D.

Other Decks in Programming

Transcript

  1. Simply Serverless Annyce Davis - @brwngrldev

  2. @brwngrldev

  3. Lambda @brwngrldev

  4. Lambda @brwngrldev

  5. Lambda @brwngrldev • Launched by AWS in 2014

  6. Lambda @brwngrldev • Launched by AWS in 2014 • Function

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

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

    as a Service (FaaS) • Typically event-driven (15 mins) • Multi-language support
  9. 1,430 @brwngrldev

  10. Serverless @brwngrldev

  11. Serverless @brwngrldev

  12. Services @brwngrldev Area Type

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

  14. Services @brwngrldev Area Type Compute Functions (Lambda) Storage Files, data

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

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

    (S3, DynamoDB) Streaming Messages, queues (SNS, SQS) Querying ETL, SQL, ML (Rekognition)
  17. Serverless @brwngrldev

  18. Serverless @brwngrldev Code runs on air

  19. Serverless @brwngrldev Code runs on air

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

  21. Code runs on air Serverless @brwngrldev Pay for what you

    use No servers to manage
  22. Code runs on air Serverless @brwngrldev Scalability provided by vendor

    Pay for what you use No servers to manage
  23. Landscape @brwngrldev On-premise Cloud native

  24. Landscape @brwngrldev On-premise Cloud native

  25. @brwngrldev

  26. Players @brwngrldev

  27. @brwngrldev

  28. Pros @brwngrldev

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

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

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

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

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

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

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

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

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

    scalability • No specialized DevOps Cons • Ecosystem immature • Vendor lock-in • Multiple moving pieces • Learning curve
  38. ServerLess @brwngrldev

  39. “Less” @brwngrldev

  40. “Less” @brwngrldev • Backend code

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

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

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

    Tech debt
  44. Getting Started @brwngrldev

  45. @brwngrldev

  46. @brwngrldev

  47. Demo @brwngrldev

  48. None
  49. None
  50. None
  51. None
  52. @brwngrldev

  53. @brwngrldev http://serverlesscalc.com

  54. @brwngrldev

  55. @brwngrldev Deploy Terraform

  56. 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
  57. @brwngrldev Deploy Terraform AWS CloudFormation Cloud Deployment Manager

  58. @brwngrldev

  59. @brwngrldev

  60. Serverless with Kotlin @brwngrldev

  61. @brwngrldev

  62. @brwngrldev Ktor Koin Kotless

  63. @brwngrldev Ktor Application

  64. @brwngrldev Ktor Application Feature Feature

  65. @brwngrldev Ktor Application Feature Feature Routes

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

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

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

    call.receive<GraphQLRequest>() … call.respondText(result) } Ktor
  69. @brwngrldev Koin val mainModule = module { single { Gson()

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

    } single { AppSchema(get()) } single { UFOSightingDatabase() } } val appSchema: AppSchema by inject() val gson: Gson by inject()
  71. @brwngrldev Kotless

  72. @brwngrldev Kotless 1. Downloads Terraform

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

  74. @brwngrldev Kotless 1. Downloads Terraform 2. Generates deployment code 3.

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

    Packs the lambda 4. Deploys the app to AWS
  76. @brwngrldev Ktor & Kotless class UFOSightingsApp : Kotless() { override

    fun prepare(app: Application) { with(app) { main() routes() } } }
  77. @brwngrldev kotless { config { } webapp { } }

  78. @brwngrldev kotless { config { bucket = "ktor-kotless-ufo.s3.adavis.info" dsl {

    type = DSLType.Ktor } terraform { profile = "default" region = "us-east-1" } } webapp { } }
  79. @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") } }
  80. @brwngrldev ./gradlew deploy

  81. @brwngrldev

  82. @brwngrldev

  83. @brwngrldev

  84. @brwngrldev

  85. Demo @brwngrldev

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

  87. @brwngrldev

  88. 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)