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

How I Built a Serverless Search for My Blog with Java, Quarkus, and AWS Lambda

How I Built a Serverless Search for My Blog with Java, Quarkus, and AWS Lambda

-- A presentation from QConPlus 2020 (https://plus.qconferences.com/plus2020/presentation/serverless-search-my-blog-java-quarkus-aws-lambda) --

A Serverless app? With Java?! Absolutely!

We’ll discuss when Serverless is a great fit (and when it isn’t!) and why you don’t need to leave the Java platform when going Serverless. Based on the real-world example of a Serverless blog search, you’ll learn how Quarkus and GraalVM help you with building apps for AWS Lambda, which are blazing fast to start up and are memory-efficient at the same time. We’ll explore

* Which options Quarkus provides for creating AWS Lambda apps, making noticeable cold-start delays a thing of the past
* What it takes to enable existing libraries like Apache Lucene to be used in GraalVM native binaries
* How to build Serverless apps which are portable across platforms, avoiding lock-in into specific cloud providers

Join us for this session to stop worrying about cold-starts and exploding costs, and learn how to love Serverless -- Java style!

Gunnar Morling

November 17, 2020

More Decks by Gunnar Morling

Other Decks in Programming


  1. (How I Built a) Serverless Search for My Blog With

    Java, Quarkus & AWS Lambda Gunnar Morling Software Engineer, Red Hat @gunnarmorling
  2. #ServerlessSearch @gunnarmorling 4 Gunnar Morling • Open source software engineer

    at Red Hat ◦ Debezium ◦ Quarkus • Spec Lead for Bean Validation 2.0 • Java Champion • @gunnarmorling
  3. #ServerlessSearch @gunnarmorling “Serverless computing refers to the concept of building

    and running applications that do not require server management. It describes a finer-grained deployment model where applications, bundled as one or more functions are uploaded to a platform and then executed, scaled, and billed in response to the exact demand needed at the moment” -- CNCF Definition, https://www.cncf.io/blog/2018/02/14/cncf-takes-first-step-towards-serverless-computing/ What is Serverless Again?
  4. #ServerlessSearch @gunnarmorling • Smaller attack surface • Lower cost •

    A learning opportunity Why Serverless For My Use Case?
  5. #ServerlessSearch @gunnarmorling Solution Overview Indexing and Searching • Hugo can

    provide searchable JSON • Indexed at build time ◦ Immutable image • Apache Lucene ◦ Stemming ◦ Highlighting ◦ Fuzzy Search
  6. #ServerlessSearch @gunnarmorling Serverless Apps with Quarkus When to Use What?

    Have existing code; specific APIs needed RequestHandler Simple GET/POST Funqy Full flexibility needed Web Stacks
  7. #ServerlessSearch @gunnarmorling • Dragons beware! ◦ Reflection ◦ Method handles

    ◦ Finding all resources ◦ JNI • Quarkus extensions for many libraries Cold Starts - A Dish Best Served Fast Native Binaries via GraalVM
  8. #ServerlessSearch @gunnarmorling Cost Control • API Usage Plan (beware of

    CORS preflight requests!) • Throttling • Budget Circuit Breaker • CloudFlare Service Workers How To Prevent “Denial-of-Wallet” Attacks?
  9. #ServerlessSearch @gunnarmorling • Steep learning curve of AWS Lambda ◦

    IAM is a tricky beast ◦ More RAM → more CPU shares • Quarkus helps; avoids lock-in ◦ SAM templates ◦ Helper scripts • Protect against “denial-of-wallet” attacks Lessons Learned
  10. #ServerlessSearch @gunnarmorling • In-depth Write-up www.morling.dev/blog/how-i-built-a-serverless-search-for-my-blog/ • Source Code github.com/gunnarmorling/search.morling.dev/

    • Quarkus quarkus.io/ • Budget circuit breaker harishkm.in/2020/07/10/automatically-shutdown-your-api-on-amazon-api- gateway-when-it-breaches-a-certain-spending-threshold/ Resources