SlideShare a Scribd company logo
1 of 48
Serverless and Java in the Real World
@johnchapin | john@symphonia.io
InfoQ.com: News & Community Site
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
serverless-java
• Over 1,000,000 software developers, architects and CTOs read the site world-
wide every month
• 250,000 senior developers subscribe to our weekly newsletter
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• 2 dedicated podcast channels: The InfoQ Podcast, with a focus on
Architecture and The Engineering Culture Podcast, with a focus on building
• 96 deep dives on innovative topics packed as downloadable emags and
minibooks
• Over 40 new content items per week
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Presented at QCon London
www.qconlondon.com
Fearless AWS
Lambdas
QCon NYC 2017

https://bit.ly/symph-qcon-fearless
Learning Lambda
Mike Roberts

mike@symphonia.io

https://bit.ly/symph-ll
Agenda
1. Choosing Java for Serverless (and AWS Lambda)

2. Structuring a Serverless Java project

3. Logging and metrics

4. Building and deploying

5. Live examples
Choosing Java for Serverless

(and AWS Lambda)
AWS Lambda runtimes
• Node.js

• Python

• Java (and Scala, Clojure, Kotlin...)

• Go

• C#

• Anything else you want, via a Node.js shim
How do we choose a runtime?
Business/Technical Decision
Is there a
requirement for
long-tail, low-latency,
synchronous
operations?
Probably not Java (or C#).
Team Decision
Does the team
have (or want to
have) experience with a
specific runtime?
Make the team happy.
The best use case for Serverless Java
Kinesis processing
Latency tolerant

Regular, frequent invocations

Not particularly bursty

Computationally intensive
Asynchronous, high-throughput
Structuring a Serverless Java Project
What is a project?
Domain-Driven
Design
Eric Evans, 2003
One service = one project
• Service = bounded context (probably)

• A "service" in the AWS Serverless world might be made up
of several Lambda functions, and some associated
infrastructure.

• The "backbone" infrastructure of the system may not
belong to a specific service (but should be owned by a
single team).
Multi-module Maven project
• Hierarchical POM files

• Parent

• Lambdas

• Libraries

• AWS Bill of Materials
(BOM) at top-level
The Lambda diet
Fewer classes = faster startup

- Ruthlessly cull dependencies

- AWS libraries can be bloated!

mvn dependency:tree, sbt dependencyStats
Other useful libraries
• https://github.com/aws/aws-lambda-java-libs

• Recently updated, more events and Log4J2 support!

• https://github.com/symphoniacloud/lambda-monitoring

• Logging + metrics, PRs welcome!
Logging and Metrics
The Present and Future of Serverless Observability
- Yan Cui, yesterday here at QCon
Logging
• System.out/err goes to CloudWatch Logs

• One “log group” per Lambda (by default)

• Within “log group”, one “log stream” per container

• From CloudWatch, can aggregate/forward
System.out.nope
• System.out.println is bad for the normal reasons

• *Real* logging is better

• Lambda runtime can add RequestId to Log4J logs

• NEW! aws-lambda-java-log4j uses Log4J 2
lambda-logging
• SLF4J + Logback

• Sane default configuration w/ AWS RequestId

• Open Source (Apache 2 license)

• io.symphonia/lambda-logging “1.0.1”

• - github.com/symphoniacloud/lambda-monitoring/
package io.symphonia;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoggingLambda {
Logger LOG = LoggerFactory.getLogger(LoggingLambda.class);
public void handler(String input) {
LOG.info("Hello, {}", input);
}
}
START RequestId: 084c7cbf Version: $LATEST
[2017-04-02 00:32:10.486] 084c7cbf INFO i.s.LoggingLambda - Hello, John
END RequestId: 084c7cbf
REPORT RequestId: 084c7cbf Duration: 1.52 ms Billed Duration: 100 ms …
CloudWatch Metrics
• No built-in business metrics

• Lambda platform metrics

• Errors, Duration, Invocations, Throttles

• Naive metrics collection approach is dangerous!

• Cloudwatch has account-level API limits 🔥
CloudWatch Metric Filters
• Built into Cloudwatch! Scalable!

• Scrape Cloudwatch Logs data using special (finicky)
patterns

• Generates and posts Cloudwatch metrics in batch
lambda-metrics
• Codahale metrics and lambda-logging

• Maven plugin builds Metric Filters to scrape logs, post to
CloudWatch Metrics

• Open Source (Apache 2 license)

• io.symphonia/lambda-metrics “1.0.1”

• github.com/symphoniacloud/lambda-monitoring
package io.symphonia;
import com.codahale.metrics.Counter;
import io.symphonia.lambda.annotations.CloudwatchMetric;
import io.symphonia.lambda.metrics.LambdaMetricSet;
import org.slf4j.*;
public class MetricLambda {
Logger LOG = LoggerFactory.getLogger(MetricLambda.class);
private class Metrics extends LambdaMetricSet {
@CloudwatchMetric
Counter inputBytes = new Counter();
}
public void handler(String input) {
Metrics metrics = new Metrics();
metrics.inputBytes.inc(input.length());
metrics.report(LOG);
}
}
START RequestId: 084c7cbf Version: $LATEST
084c7cbf METRIC i.s.Lambda type COUNTER name 
io.symphonia.Lambda.Metrics/inputBytes count 3
END RequestId: 084c7cbf
REPORT RequestId: 084c7cbf Duration: 1.52 ms Billed 
Duration: 100 ms …
[request_id, level=METRIC, logger, type_label,
type=COUNTER, name_label,
name=”io.symphonia.Lambda.Metrics/inputBytes”,
count_label, count]
START RequestId: 084c7cbf Version: $LATEST
084c7cbf METRIC i.s.Lambda type COUNTER name 
io.symphonia.Lambda.Metrics/inputBytes count 3
END RequestId: 084c7cbf
REPORT RequestId: 084c7cbf Duration: 1.52 ms Billed 
Duration: 100 ms …
[request_id, level=METRIC, logger, type_label,
type=COUNTER, name_label,
name=”io.symphonia.Lambda.Metrics/inputBytes”,
count_label, count]
START RequestId: 084c7cbf Version: $LATEST
084c7cbf METRIC i.s.Lambda type COUNTER name 
io.symphonia.Lambda.Metrics/inputBytes count 3
END RequestId: 084c7cbf
REPORT RequestId: 084c7cbf Duration: 1.52 ms Billed 
Duration: 100 ms …
[request_id, level=METRIC, logger, type_label,
type=COUNTER, name_label,
name=”io.symphonia.Lambda.Metrics/inputBytes”,
count_label, count]
Building and Deploying
Continuous Delivery in an Ephemeral World
O'Reilly SACON NYC 2018

https://conferences.oreilly.com/software-architecture/sa-ny/public/schedule/detail/63860
Build pipeline
• Infrastructure as code!

• AWS CodePipeline / CodeBuild

• Separate repository

• e.g., "serverless-app-build" repository

• Cache dependencies (via CodeBuild caching)
Application and infrastructure
• Continuously deploy code *and* infrastructure
• Alongside the application source code

• buildspec.yml
• sam.yml
SAM vs Serverless Framework
• Serverless Application Model

• AWS-specific

• Different flavor of CloudFormation

• Serverless Framework

• 3rd-party, supports multiple cloud vendors

• CloudFormation under the hood (for AWS)

• Plugin architecture
Reproducible builds
• Maven-produced JAR files are non-deterministic

• Datetime stamp in "pom.properties"

• Other timestamps, file ordering, etc

• SAM relies on file hashes to detect updates
Examples
https://github.com/symphoniacloud/qcon-london-2018
Flash sale!
http://bit.ly/symph-qcon-2018-demo
In conclusion
• For the right use-case, choose the Java runtime!

• Services = multi-module Maven projects

• Log and collect metrics correctly and scalably

• Infrastructure as code, continous delivery are paramount
Questions?
@johnchapin | john@symphonia.io
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
serverless-java

More Related Content

More from C4Media

Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsC4Media
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechC4Media
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/awaitC4Media
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaC4Media
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayC4Media
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?C4Media
 
CockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseCockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseC4Media
 
A Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with BrooklinA Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with BrooklinC4Media
 

More from C4Media (20)

Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery Teams
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in Adtech
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/await
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven Utopia
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?
 
CockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL DatabaseCockroachDB: Architecture of a Geo-Distributed SQL Database
CockroachDB: Architecture of a Geo-Distributed SQL Database
 
A Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with BrooklinA Dive into Streams @LinkedIn with Brooklin
A Dive into Streams @LinkedIn with Brooklin
 

Recently uploaded

Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfUK Journal
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfFIDO Alliance
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGDSC PJATK
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 

Recently uploaded (20)

Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 

Serverless and Java in the Real World

  • 1. Serverless and Java in the Real World @johnchapin | john@symphonia.io
  • 2. InfoQ.com: News & Community Site Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ serverless-java • Over 1,000,000 software developers, architects and CTOs read the site world- wide every month • 250,000 senior developers subscribe to our weekly newsletter • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • 2 dedicated podcast channels: The InfoQ Podcast, with a focus on Architecture and The Engineering Culture Podcast, with a focus on building • 96 deep dives on innovative topics packed as downloadable emags and minibooks • Over 40 new content items per week
  • 3. Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide Presented at QCon London www.qconlondon.com
  • 4.
  • 5. Fearless AWS Lambdas QCon NYC 2017 https://bit.ly/symph-qcon-fearless
  • 7. Agenda 1. Choosing Java for Serverless (and AWS Lambda) 2. Structuring a Serverless Java project 3. Logging and metrics 4. Building and deploying 5. Live examples
  • 8. Choosing Java for Serverless
 (and AWS Lambda)
  • 9. AWS Lambda runtimes • Node.js • Python • Java (and Scala, Clojure, Kotlin...) • Go • C# • Anything else you want, via a Node.js shim
  • 10. How do we choose a runtime?
  • 11. Business/Technical Decision Is there a requirement for long-tail, low-latency, synchronous operations? Probably not Java (or C#).
  • 12. Team Decision Does the team have (or want to have) experience with a specific runtime? Make the team happy.
  • 13. The best use case for Serverless Java
  • 14. Kinesis processing Latency tolerant Regular, frequent invocations Not particularly bursty Computationally intensive
  • 16. Structuring a Serverless Java Project
  • 17. What is a project?
  • 18.
  • 20. One service = one project • Service = bounded context (probably) • A "service" in the AWS Serverless world might be made up of several Lambda functions, and some associated infrastructure. • The "backbone" infrastructure of the system may not belong to a specific service (but should be owned by a single team).
  • 21.
  • 22. Multi-module Maven project • Hierarchical POM files • Parent • Lambdas • Libraries • AWS Bill of Materials (BOM) at top-level
  • 23. The Lambda diet Fewer classes = faster startup - Ruthlessly cull dependencies - AWS libraries can be bloated! mvn dependency:tree, sbt dependencyStats
  • 24. Other useful libraries • https://github.com/aws/aws-lambda-java-libs • Recently updated, more events and Log4J2 support! • https://github.com/symphoniacloud/lambda-monitoring • Logging + metrics, PRs welcome!
  • 26. The Present and Future of Serverless Observability - Yan Cui, yesterday here at QCon
  • 27. Logging • System.out/err goes to CloudWatch Logs • One “log group” per Lambda (by default) • Within “log group”, one “log stream” per container • From CloudWatch, can aggregate/forward
  • 28. System.out.nope • System.out.println is bad for the normal reasons • *Real* logging is better • Lambda runtime can add RequestId to Log4J logs • NEW! aws-lambda-java-log4j uses Log4J 2
  • 29. lambda-logging • SLF4J + Logback • Sane default configuration w/ AWS RequestId • Open Source (Apache 2 license) • io.symphonia/lambda-logging “1.0.1” • - github.com/symphoniacloud/lambda-monitoring/
  • 30. package io.symphonia; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class LoggingLambda { Logger LOG = LoggerFactory.getLogger(LoggingLambda.class); public void handler(String input) { LOG.info("Hello, {}", input); } } START RequestId: 084c7cbf Version: $LATEST [2017-04-02 00:32:10.486] 084c7cbf INFO i.s.LoggingLambda - Hello, John END RequestId: 084c7cbf REPORT RequestId: 084c7cbf Duration: 1.52 ms Billed Duration: 100 ms …
  • 31. CloudWatch Metrics • No built-in business metrics • Lambda platform metrics • Errors, Duration, Invocations, Throttles • Naive metrics collection approach is dangerous! • Cloudwatch has account-level API limits 🔥
  • 32. CloudWatch Metric Filters • Built into Cloudwatch! Scalable! • Scrape Cloudwatch Logs data using special (finicky) patterns • Generates and posts Cloudwatch metrics in batch
  • 33. lambda-metrics • Codahale metrics and lambda-logging • Maven plugin builds Metric Filters to scrape logs, post to CloudWatch Metrics • Open Source (Apache 2 license) • io.symphonia/lambda-metrics “1.0.1” • github.com/symphoniacloud/lambda-monitoring
  • 34. package io.symphonia; import com.codahale.metrics.Counter; import io.symphonia.lambda.annotations.CloudwatchMetric; import io.symphonia.lambda.metrics.LambdaMetricSet; import org.slf4j.*; public class MetricLambda { Logger LOG = LoggerFactory.getLogger(MetricLambda.class); private class Metrics extends LambdaMetricSet { @CloudwatchMetric Counter inputBytes = new Counter(); } public void handler(String input) { Metrics metrics = new Metrics(); metrics.inputBytes.inc(input.length()); metrics.report(LOG); } }
  • 35. START RequestId: 084c7cbf Version: $LATEST 084c7cbf METRIC i.s.Lambda type COUNTER name io.symphonia.Lambda.Metrics/inputBytes count 3 END RequestId: 084c7cbf REPORT RequestId: 084c7cbf Duration: 1.52 ms Billed Duration: 100 ms … [request_id, level=METRIC, logger, type_label, type=COUNTER, name_label, name=”io.symphonia.Lambda.Metrics/inputBytes”, count_label, count]
  • 36. START RequestId: 084c7cbf Version: $LATEST 084c7cbf METRIC i.s.Lambda type COUNTER name io.symphonia.Lambda.Metrics/inputBytes count 3 END RequestId: 084c7cbf REPORT RequestId: 084c7cbf Duration: 1.52 ms Billed Duration: 100 ms … [request_id, level=METRIC, logger, type_label, type=COUNTER, name_label, name=”io.symphonia.Lambda.Metrics/inputBytes”, count_label, count]
  • 37. START RequestId: 084c7cbf Version: $LATEST 084c7cbf METRIC i.s.Lambda type COUNTER name io.symphonia.Lambda.Metrics/inputBytes count 3 END RequestId: 084c7cbf REPORT RequestId: 084c7cbf Duration: 1.52 ms Billed Duration: 100 ms … [request_id, level=METRIC, logger, type_label, type=COUNTER, name_label, name=”io.symphonia.Lambda.Metrics/inputBytes”, count_label, count]
  • 39. Continuous Delivery in an Ephemeral World O'Reilly SACON NYC 2018 https://conferences.oreilly.com/software-architecture/sa-ny/public/schedule/detail/63860
  • 40. Build pipeline • Infrastructure as code! • AWS CodePipeline / CodeBuild • Separate repository • e.g., "serverless-app-build" repository • Cache dependencies (via CodeBuild caching)
  • 41. Application and infrastructure • Continuously deploy code *and* infrastructure • Alongside the application source code • buildspec.yml • sam.yml
  • 42. SAM vs Serverless Framework • Serverless Application Model • AWS-specific • Different flavor of CloudFormation • Serverless Framework • 3rd-party, supports multiple cloud vendors • CloudFormation under the hood (for AWS) • Plugin architecture
  • 43. Reproducible builds • Maven-produced JAR files are non-deterministic • Datetime stamp in "pom.properties" • Other timestamps, file ordering, etc • SAM relies on file hashes to detect updates
  • 46. In conclusion • For the right use-case, choose the Java runtime! • Services = multi-module Maven projects • Log and collect metrics correctly and scalably • Infrastructure as code, continous delivery are paramount
  • 48. Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ serverless-java