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

Serverless computing for Java developers

Serhat Can
February 28, 2019

Serverless computing for Java developers

Java hasn’t been a popular language in AWS Lambda or any other Serverless computing solution. There are some reasons like lack of easy to use libraries, cold starts, and monitoring. I’ll talk about these issues and show some use-cases from Opsgenie on how we leverage this new paradigm. I’ll close the talk with some specific suggestions for Java devs.

Serhat Can

February 28, 2019
Tweet

More Decks by Serhat Can

Other Decks in Technology

Transcript

  1. @srhtcn Who am I? • Ex-Software Engineer Technical Evangelist at

    • AWS Community Hero • Devopsdays core team member • Organizer Serverless Turkey meetup and Devops Turkey meetup • Podcast Turuncu Pasaport • @srhtcn on Twitter
  2. @srhtcn You want to run code on cloud. Your options:

    Bare metal IaaS (VM) CaaS (container) PaaS (app) Serverless (function) More control, more code Less control, less code
  3. @srhtcn Making thoughtful decisions about tools and architecture can help;

    well-considered constraints can free us from the decisions that aren't bringing us distinguishable benefit. Bridget Kromhout https://queue.acm.org/detail.cfm?id=3185224
  4. @srhtcn Defining Serverless Serverless is an event driven, utility based,

    stateless, code execution environment. Simon Wardley @swardley
  5. @srhtcn Defining Serverless Event driven: Code is initiated and run

    after an event like HTTP request or storage of a file triggers.
  6. @srhtcn Defining Serverless Event driven: Code is initiated and run

    after an event like HTTP request or storage of a file triggers. Utility based: No payment for idle time or hosting. You pay for the resources you use when your code is triggered.
  7. @srhtcn Defining Serverless Event driven: Code is initiated and run

    after an event like HTTP request or storage of a file triggers. Utility based: No payment for idle time or hosting. You pay for the resources you use when your code is triggered. Stateless: Code execution environment is deconstructed after sometime. No information is guaranteed to stay in the environment after function execution is completed.
  8. @srhtcn Defining Serverless Event driven: Code is initiated and run

    after an event like HTTP request or storage of a file triggers. Utility based: No payment for idle time or hosting. You pay for the resources you use when your code is triggered. Stateless: Code execution environment is deconstructed after sometime. No information is guaranteed to stay in the environment after function execution is completed. Code execution: Just code, not servers / VMs / containers etc.
  9. @srhtcn ServerLess is more Less code to maintain, less ops,

    less toil • Scaling • Provisioning • OS or Language updates • Resource utilization • Network monitoring • Fault tolerance • Shipping logs https://landing.google.com/sre/book/chapters/eliminating-toil.html
  10. @srhtcn Economics No payment for idle time or hosting Easy

    to get started Faster time to market
  11. @srhtcn Java in a Serverless World • AWS Lambda: Java

    8 and more details soon! • Google Cloud Functions: no Java support
  12. @srhtcn Java in a Serverless World • AWS Lambda: Java

    8 and more details soon! • Google Cloud Functions: no Java support • Azure Functions: Java 8 for Azure Functions is currently in preview (GA 3 days ago!)
  13. @srhtcn Java in a Serverless World • AWS Lambda: Java

    8 and more details soon! • Google Cloud Functions: no Java support • Azure Functions: Java 8 for Azure Functions is currently in preview (GA 3 days ago!) • IBM Cloud Functions: Java 8 and bring your own language via Docker
  14. @srhtcn Java in a Serverless World • AWS Lambda: Java

    8 and more details soon! • Google Cloud Functions: no Java support • Azure Functions: Java 8 for Azure Functions is currently in preview (GA 3 days ago!) • IBM Cloud Functions: Java 8 and bring your own language via Docker • Oracle’s FN Project: container native, cloud agnostic serverless platform
  15. @srhtcn Language support Node.js (JavaScript) Python, Java (Java 8 compatible),

    C# (.NET Core), Golang, Ruby NEW: Bring your own language!
  16. @srhtcn Pricing You choose memory size % of CPU core

    and network capacity increases proportionally with memory More memory doesn’t always mean you pay more
  17. @srhtcn Supported event sources 20 different services can trigger AWS

    Lambda functions including. Event sources that aren't stream-based: Synchronous invocation: Asynchronous invocation: Poll-based (or pull model) event sources that are stream-based: Poll-based event sources that are not stream-based:
  18. @srhtcn Toolkit around AWS Lambda Orchestration: Step Functions Deployment: SAM,

    Serverless.js, CloudFormation, Apex, Terraform Monitoring: X-Ray, Thundra Marketplace: AWS Serverless Application Repository
  19. @srhtcn AWS Lambda at OpsGenie AWS Lambda with Java 8

    DynamoDB SQS SNS VPC Serverless.js
  20. @srhtcn Fast scaling under immediate high load Under-utilized machines Pricing

    (still not a huge concern) Operational complexity Learning curve - kubernetes? AWS Fargate - YES Why did we consider AWS Lambda?
  21. @srhtcn OpsGenie’s Serverless journey 2015 Writing small scale custom integrations

    At this point, we started leveraging AWS Lambda to help our customer run custom code
  22. @srhtcn OpsGenie’s Serverless journey 2015 Writing small scale custom integrations

    At this point, we started leveraging AWS Lambda to help our customer run custom code First production usage Started using AWS Lambda for leveraging async / not business critical jobs such as DynamoDB autoscale 2016
  23. @srhtcn OpsGenie’s Serverless journey 2015 Writing small scale custom integrations

    At this point, we started leveraging AWS Lambda to help our customer run custom code First production usage Started using AWS Lambda for leveraging async / not business critical jobs such as DynamoDB autoscale 2016 Service and Incident Management A new customer facing feature running on AWS Lambda integrated with the rest of the code base. 2017
  24. @srhtcn OpsGenie’s Serverless journey 2015 Writing small scale custom integrations

    At this point, we started leveraging AWS Lambda to help our customer run custom code First production usage Started using AWS Lambda for leveraging async / not business critical jobs such as DynamoDB autoscale 2016 Service and Incident Management A new customer facing feature running on AWS Lambda integrated with the rest of the code base. 2017 A Spin Off: Thundra Observability for AWS Lambda 2018
  25. @srhtcn Custom integrations AWS Lambda is a life saver for

    custom solutions, because; ◦ Customers do not need to manage servers ◦ Easy to get started and deploy (give a .zip file) ◦ Real pay what you use pricing
  26. @srhtcn Challenges • Monitoring and debugging • Cold start •

    Local development • Concurrent execution limit • No well-known good practices
  27. @srhtcn Fixing “it is slow” is harder in AWS Lambda

    Too many moving pieces No way to attach an agent Even how to send the monitoring data is a discussion point
  28. @srhtcn Determine the latency in different levels Automatic instrumentation GC,

    Thread counts & durations, CPU usage details Get the stack trace in case of an error and drill down See logs, traces, and metrics in one view thundra.io What we needed was
  29. @srhtcn Lessons learned: An incident of $40,000 Avoid infinite retries

    Monitor and alert for pricing (no pricing metric for AWS Lambda) Think of Cloudwatch cost and sample logs & metrics
  30. @srhtcn Cold start When: - memory size - code size

    - VPC - the language https://read.acloud.guru/does-coding-language-memory-or-package-size-affect-cold-starts-of-aws-lambda-a15e26d12c76
  31. @srhtcn Solving cold start problem Wait for AWS to improve

    it Increase memory (and pay more) Lightweight application framework instead of Spring Do some smart warm-up
  32. @srhtcn Account level concurrent execution limit Lambda concurrent execution count

    for non stream based events: events (or requests) per second * function duration
  33. @srhtcn Account level concurrent execution limit Lambda concurrent execution count

    for non stream based events: events (or requests) per second * function duration Hard to deal with peaks in request numbers Takes time to increase the limit Functions affect each other’s scalability
  34. @srhtcn Latency in a third party can bring your whole

    system down https://read.acloud.guru/does-aws-lambda-keep-its-serverless-marketing-promise-of-continuous-scaling-e990114bb379
  35. @srhtcn Function level concurrent execution limit Limit the scalability of

    non-critical functions Reserved capacity is subtracted from the global limit
  36. @srhtcn Don’t put your functions in a VPC unless you

    have to You need sufficient IP addresses in your subnet and ENI to scale https://docs.aws.amazon.com/lambda/latest/dg/vpc.html Determine the ENI capacity you need: Concurrent executions * (Memory in GB / 3 GB)
  37. @srhtcn Serverless computing will become the default computing paradigm of

    the Cloud Era. @srhtcn https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.pdf