January 2017 - Deep dive on AWS Lambda and DevOps

Post on 13-Apr-2017

29 views 2 download

Transcript of January 2017 - Deep dive on AWS Lambda and DevOps

AWS Users’ Group UpdatesDavid “Mac” McDanielSr. Solution & Cloud Architectdmcdaniel@microstarkegs.com / david@mobile-360.comLinkedIn: https://www.linkedin.com/in/davidbmcdanielTwitter: @CloudKegGuy, @ServerlessJavaTwitter list: https://twitter.com/CloudKegGuy/lists/aws/members

New AWS Users’ Group Items

Slack Channel: https://DenverAWSUsersGroup.slack.com

You will need an invitation to join, please email me: david@mobile-360.com.

Survey will be going out before next meeting!

Channels include:

● #general for any questions● #i-a-a-s for Infrastructure (Servers etc) as a Service questions/discussions● #p-a-a-s for Platform as a Service questions/discussions● More?

Next Month’s TOPIC:

????

We need speakers!

How big is Amazon anyway?

Progression of “As A Service” models

Software as a Service: Multi-tenant, provider-hosted software - Salesforce.com

Infrastructure as a Service: Multi-tenant, provider-hosted operating systems

Platform as a Service: A specific piece of functionality as a service - queuing, emailing, storing, etc

Function as a Service: Deploying your own code - as a service.Benefits: No servers to manage, Microservice architecture, smaller deployable units, pay by the second billing, automatic logging, etc.

Lambdas: Amazon’s FaaS● Program in Java, Node.js, Python, C# - more coming● Mix-and-match languages in different Lambdas● Easily connect to DynamoDB, S3, SQS, SNS etc● Easy integration with API Gateway● Lambda can serve as event target for SQS, SNS, S3 Events, Dynamo, Kinesis,

Aurora● Can run within IoT device and on AWS’s Edge network● Excellent for RESTful service implementation - single resource/single method,

single resource/multiple method or multiple resource/multiple method

Lambda

Lambdas

Step Functions - Coordinates Lambdas

Ways to call Lambdas

Architecture in Lambdas

Changes focus of architecture and centers it more around the domain rather than on infrastructure of your system.

Almost forces moving away from monolithic architecture into more component or functional architecture.

Creates better division of responsibilities/separation of concerns.

Allows for better re-use and service combining.

Automatic and virtually unlimited scaling.

Lambda ArchitectureIoT

StepFunction

Different Architectural Styles

I’ve created what I call “Domain Service Architecture”.

Major Architecture Styles:

1. Monolithic (ex: 2-Tier Client/Server, Mainframe)2. Services Oriented Architecture (too generic):

a. Micro Service - every operation has different implementation/functioni. Some people state that every service should have own persistence

b. Macro Service - somewhere in between Monolithic and Microc. Domain Service - encompasses everything about a small domain of the system.d. Functional Service - every function has own service; similar to Micro

Architecture Advantages of “Domain” Services● In RESTful terms, Domain = Resource; In DB terms, Domain = Table

(+Supporting tables)● Encompasses all operations on the Domain object - therefore doesn’t force

multiple services/functions to handle one domain object! This is big!● Allows composition of multiple Domain Services into Business Service● UI’s use both Business Services and Domain Services● Smaller Testing units● Smaller & Faster deployment units● Lower risk because smaller deployment unit =

less change per deployment● Decouples different domains from each other.

id: ...Name: varcharAttr1: …Attr2: ….ShipAddrId: ...Etc: ...

Customer

id: ...CustId: ...ContactId: …AddressId: [...]Etc: ...

CustomerContactLink

id: ...FName: ...LName: ...Phone: ...Etc: ...

Contact

id: ...OriginId: ...DestId: ...OrderDate: dateEtc: ...

Shipments

Contact Domain Shipments Domain

Customer Domainid: ...Name: varcharAddr1: …Addr2: ….Etc: ...

Address

Domain Service Architecture example

DevOps Differences

● Smaller, Faster deployments● Ability to mix-and-match programming languages● Incremental deployments now possible● No long dev-test-qa-deploy cycle● Smaller, more responsive teams● Less overhead in coordination of deployments/development

Maven Project: MASTER

Maven Project: Shipments

Maven Project: Customers

Maven Project: Contacts

DB Object: Contact

DB Object: CCLink

DB Object: Address

DB Object: Customer

DB Object: ShipmentWeak Ref

(ID only)

Weak Ref(ID only)

@DELETE@Path("/{id}")public Response deleteContact(@PathParam("id") String id){

LOG.debug("Entering contacts::DELETE /" + id);...

}@POST@Consumes({MediaType.APPLICATION_JSON})@Produces({MediaType.APPLICATION_JSON})public Response createContact(ContactObject co){

LOG.debug("Entering contacts::POST");…

}@PUT@Path("/{id}")@Produces({MediaType.APPLICATION_JSON})@Consumes({MediaType.APPLICATION_JSON})public Response updateContact(@PathParam("id") String id, ContactObject co){

LOG.debug("Entering contacts::PUT /" + id);…

}@GET@Produces({MediaType.APPLICATION_JSON})public Response getByCustId(@QueryParam("cid") String cid){

LOG.info("Entering contacts::GET ?cid=" + cid);…

}

Important Libraries

1. JAX-RS/Jersey/Jackson: For @GET/@Path/etc Annotations and automatic conversion of Objects to JSON and JSON to Objects.

2. JRestless: Interface between Lambda and Jersey.3. Hibernate: Persistence ORM.4. Swagger: Automatically creates API definition files.5. ServerlessJava: Builds, deploys, configures, versions Java Lambdas.

Questions?