Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Serverless Java Journey - Geecon 2018

203 views

Published on

Let me tell you a real story of running serverless Java applications: - Maneuvering around limitations of AWS Lambda functions, but at the same time saving a lot of money on infrastructure. - Tuning your code for fast initialization to reduce cold start times and avoid timeouts in upstreams integrations. - Sharing experience with different languages like plain-old-Java, Groovy, Kotlin as well as frameworks like Spring and Micronaut. - Going through some operational overhead of managing resources that compose serverless environment with Terraform and Serverless.com framework. - Dealing with debugging and local testing of your functions. - Collecting and observing metrics and logging data.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Serverless Java Journey - Geecon 2018

  1. 1. 01
  2. 2. 02
  3. 3. 03
  4. 4. Let's start! 04
  5. 5. What is serverless? 05
  6. 6. Look ma, no servers! 06
  7. 7. Serverless is meaningless! 07
  8. 8. Responsive design? 08
  9. 9. Serverless I do not want to care about the servers! “ 09
  10. 10. Serverless may also mean Containerless/Dockerless Orchestratorless/Kubernetesless • • 10
  11. 11. Serverless != FaaS 11
  12. 12. Serverless != Operationless 12
  13. 13. Lost professions 13
  14. 14. Serverless = Servicefull 14
  15. 15. Idea to production 15
  16. 16. Serverless = IaU 16
  17. 17. Cheaper than servers 17
  18. 18. Serverless is a billing model! 18
  19. 19. Pay-as-you- go 19
  20. 20. FaaS 20
  21. 21. Typical questions How do I configure DB inside my function? How do I add storage into my function? How do I install package X into my function? • • • 21
  22. 22. You don't! 22
  23. 23. Built-in features Logging and auditing Rate limits Auto-scaling Security controls Multiple versions Simplified deployment • • • • • • 23
  24. 24. Bought-in services Database-as-a-service Storage-as-a-service Messaging-as-a-service Function-as-a-service • • • • 24
  25. 25. BaaS 25
  26. 26. If it were 2008... Jetty/Tomcat (on a server) MySQL, HSQL, Sqlite (on a server) File system (on a server) • • • 26
  27. 27. If it were 2015... Jetty/Tomcat (in a container on a server) or PaaS in the cloud MySQL, HSQL, Sqlite (on a server or in a container on a server) or DaaS in the cloud File system (in a volume on a server) or object storage in the cloud • • • 27
  28. 28. In 2018... CDN + FaaS + LB in the cloud DaaS in the cloud Object storage in the cloud • • • 28
  29. 29. Benefits No baby sitting with our infrastructure Less accumulating technical debt Minimise operations effort Minimise cost of unused resources • • • • 29
  30. 30. FaaS pains Memory size Archive size CPU count Cold starts Long deployment times Vendor lock-in Limited runtime verions Rate limits on external/internal traffic • • • • • • • • 30
  31. 31. FaaS offerings (generic cloud) Google Cloud Plafotm Azure IBM OpenWhisk AWS Zeit • • • • • 31
  32. 32. FaaS offerings (specialized) Cloudflare.com Web Workers Firebase Functions Webtask.io (Chat Bots, Web Hooks) Zapier.com (API Integrations) Glitch.com (Chat Bots) • • • • • 32
  33. 33. Java FaaS 33
  34. 34. Java FaaS in the cloud AWS Lambda - yes, since 2015 IBM OpenWhisk - yes, since 2017 Oracle Cloud Functions - yes, but... Azure Functions - in preview mode Google Cloud Functions - no, but GAE Zeit - yes, with the help of Docker • • • • • • 34
  35. 35. Java FaaS on IaaS Kubeless Knative Fn Project OpenFaas Apache OpenWhisk • • • • • 35
  36. 36. The journey... 36
  37. 37. Latcraft 37
  38. 38. Step 1 I want to create a lambda function that will do image generation and maybe some other tasks. “ 38
  39. 39. Step 2 Cool, I already have the code for that in the form of Groovy scripts. How do I deploy? I need to package it differently. Ok, deployed!“ 39
  40. 40. Step 4 How do I call it? I need to call it through AWS API. Calling it... Hmm, function failed, where are the logs? Hmm, missing security policy. “ 40
  41. 41. Step 5 How do I call it without the need to install AWS SDK? API gateway is the answer! Ok, but how do I return an image from API gateway? Well, it is possible, but it requires some extra config. Well, actually EXTRA CONFIG! Ok, but still how do I get an image? Maybe upload it to S3 instead and return a link? “ 41
  42. 42. Step 6 Ok, let's integrate it with Slack. /craftbot generate image ... timeout /craftbot generate image ... timeout /craftbot generate image ... http://... Hmm, Slack waits only for 3 seconds for command to return “ 42
  43. 43. Simple? No! 43
  44. 44. Cold starts and timeouts Lambda function will time out after max. 300 seconds (900 seconds in 2018) API gateway will time out after 30 seconds Slack hook will time out after 3 seconds • • • 44
  45. 45. JVM warm-up 45
  46. 46. Routing function 46
  47. 47. Callback channel 47
  48. 48. Cron event 48
  49. 49. Final setup 49
  50. 50. Tools 50
  51. 51. Terraform 51
  52. 52. Serverless 52
  53. 53. Alternatives Claudia.js Apex Shep Amplify most likely someone is writing one more right now • • • • • 53
  54. 54. Demo: Plain Old Java 54
  55. 55. Micronaut 55
  56. 56. Demo: Micronaut with Java56
  57. 57. Demo: Micronaut with Groovy57
  58. 58. Dashbird 58
  59. 59. Attack! 59
  60. 60. Attack! http://bit.ly/GEECON_ATTACK• 60
  61. 61. Next project 61
  62. 62. dev.tube 62
  63. 63. Peak time 63
  64. 64. Sorry, no Java! 64
  65. 65. Node.js 65
  66. 66. Cold start is my problem! 66
  67. 67. GCP 67
  68. 68. Still a chance for Java? CDS (class data sharing) support AOT (ahead of time compilation) support GraalVM support Minimal Java 9+ without old libraries (CORBA?) • • • • 68
  69. 69. CDS 69
  70. 70. AOT 70
  71. 71. GraalVM 71
  72. 72. GraalVM + Netty 72
  73. 73. GraalVM + Go + AWS 73
  74. 74. GraalVM + Go + AWS 74
  75. 75. Conclusion Java is definitely useful in FaaS space. Tools (Terraform, Serverless.com, AWS SAM CLI) and libraries (Micronaut) help with resource management, deployment and testing. Better support for post-Java-8 features and maybe GraalVM from cloud providers is required to make it awesome! Developer experience needs improvement and it is improving each day! • • • • 75
  76. 76. The journey continues... 76
  77. 77. Thank you! 77
  78. 78. 78
  79. 79. Links & References 79
  80. 80. Projects https://serverless.com/ https://kubeless.io/ http://fnproject.io/ https://openfaas.com/ https://fission.io/ https://openwhisk.apache.org/ https://www.iron.io/ • • • • • • • 80
  81. 81. Blog posts Dealing with cold starts How long does AWS keep your idel functions Native dependencies with AWS Lambda Running executables in AWS Lambda • • • • 81
  82. 82. Blog posts Serverless native Java functions using GraalVM and Fn project Native Java using GraalVM in AWS Lambda with Go Instant Netty startup using GraalVM native image • • • 82

×