Top Banner
Moving Complex Enterprise Ecommerce Systems to the Cloud Eddie Chan Ronald Chen Elastic Path™
53

Moving complex enterprise ecommerce systems to the cloud

Nov 02, 2014

Download

Technology

Elastic Path

Developing and operating an enterprise commerce ecosystem, with its complex integrations, can often be a significant challenge. Are you wondering if a migration to the cloud would be best for your business, or if it is even possible for your specific applications? In this webinar we will discuss some of the advantages and disadvantages of working in a Platform-as-a-Service (PaaS) environment, such as dealing with restricted classes, leveraging automatic scalability, and migrating the persistence layer. Learn from our experiences, as we reveal what worked best as we moved our own multi-server enterprise application from traditional collocated hardware into the Google App Engine cloud environment.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 2: Moving complex enterprise ecommerce systems to the cloud
Page 3: Moving complex enterprise ecommerce systems to the cloud

Elastic Path Software

• We help the worldʼs biggest brands sell digital goods and services

• We provide a flexible Java ecommerce platform and expertise in ecommerce strategy and implementation

• #1 ecommerce blog: www.getelastic.com• For more on-demand ecommerce resources:

www.elasticpath.com/resources

Page 4: Moving complex enterprise ecommerce systems to the cloud

Elastic Path Architecture Components

Mobile BrowserWeb Browser Commerce Manager Client

Eclipse RCP SWT / JFace

Financials ERPSystem

CMSSystem

LegacySystems

Custom /LOB Apps

PaymentGateway

Database Server

Store Front Server

Spring Security

Core Engine

Drools

Spring MVC

Apache Velocity

Commerce Manager

Spring Security

Core Engine

Quartz Scheduling

Spring Remoting

Web Services Server

Spring Security

Core Engine

JAX-WS

SOLR Search Server Core Engine

Search Server

Quartz Scheduling

ETL Tools

XML Import/Export

Core Engine

Data Sync Tool

Core Engine

J2EE Application Server

The Elastic Path Platform

Ecommerce is complex.Enterprise ecommerce is complex-er.

Page 5: Moving complex enterprise ecommerce systems to the cloud

Case Study

• Since 2008, Elastic Path has been the ecommerce backbone of a few of Googleʼs online stores

• For these stores, many customizations have been made to the Elastic Path platform.

• One of the largest customizations thatʼs been made to the Elastic Path platform is migrating it to run on Google App Engine.

Page 6: Moving complex enterprise ecommerce systems to the cloud

Migration to Google App Engine

• EP running in the Colo• Fixed Cluster

Before: After:

• EP running on App Engine• Dynamic instances

Page 7: Moving complex enterprise ecommerce systems to the cloud

Google App Engine

• Same system that powers many of Googleʼs own apps• GAE is a Platform as a Service (PaaS)• More restrictive than Infrastructure as a Service (IaaS)

offerings (but for good reasons)• Supports Python, Go, and Java (& other JVM

languages)• Free to get started; pay as you go pricing

Page 8: Moving complex enterprise ecommerce systems to the cloud

Advantages of Google App Engine

• Automatic Scalability• Well defined development environment• Secure• Easier deployments and operations• Reduced Cost• Built-in monitoring tools• Useful services

Page 9: Moving complex enterprise ecommerce systems to the cloud

Topics

• Challenges with Restricted Classes• How App Engine Automatically Scales• Performance, Performance, Performance• Migrating the Persistence Layer

Page 10: Moving complex enterprise ecommerce systems to the cloud

Topics

• Challenges with Restricted Classes• How App Engine Automatically Scales• Performance, Performance, Performance• Migrating the Persistence Layer

Page 11: Moving complex enterprise ecommerce systems to the cloud

Challenges with Restricted Classes

• App Engineʼs JRE Class White List:

The full list of white list classes can be found at:http://code.google.com/appengine/docs/java/jrewhitelist.html

These JRE Classes work on App Engine. All other JRE Classes do not.

Page 12: Moving complex enterprise ecommerce systems to the cloud

File Restrictions

• Not allowed:• Reading/writing to the filesystem

(this should not be done anyway)• Writing to files inside the WAR• Allowed:• Reading from files inside the WAR

Page 13: Moving complex enterprise ecommerce systems to the cloud

Example: File Restrictions

• Problem: we were reading/writing to the filesystem• Solution: we moved the read-only files into the WAR

and moved the read/write data to the Datastore

Before: After:

Page 14: Moving complex enterprise ecommerce systems to the cloud

Socket Restrictions

• App Engine does not allow the use of raw sockets• Reason: security considerations• Workarounds may exist depending on the nature of

the communication• e.g. HTTP sockets & App Engine URL Fetch Service

Page 15: Moving complex enterprise ecommerce systems to the cloud

Example: Socket Restrictions

Before: After:

• Problem: We used HttpClient, which uses sockets, for Spring HTTP Remoting

• Solution: There is a custom connection manager for HttpClient 4 that uses App Engine URL Fetch Service instead of sockets

Page 16: Moving complex enterprise ecommerce systems to the cloud

Thread Restrictions

• App Engine does not allow spawning of threads• Use Task Queues instead of threads for background

jobs• Task Queues:• Like a Java Executor• Highly configurable• Accepts URLs instead of Runnables• Code that would have been in Runnable is bound to

a URL• Fetching the URL is like running the task on another

thread

Page 17: Moving complex enterprise ecommerce systems to the cloud

Example: Thread Restrictions

Before: After:

• Problem: Generating a file on a background thread• Solution: Migrate Runnable to Spring Controller and

schedule with App Engine Task Queues instead of Executor

Page 18: Moving complex enterprise ecommerce systems to the cloud

Topics

• Challenges with Restricted Classes• How App Engine Automatically Scales• Performance, Performance, Performance• Migrating the Persistence Layer

Page 19: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

“App Engine apps are powered by any number of dynamic instances at any given time, depending on the volume of requests received by your application. As requests for your application increase, so do the number of dynamic instances powering it.”

http://code.google.com/appengine/docs/adminconsole/instances.html

Requests Instances Requests Instances

Page 20: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

• A single instance handling requests• This instance, like all instances, has a request queue to

hold incoming requests

Page 21: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

• A new request comes in• Instance-1ʼs request queue is getting overloaded, so...

Page 22: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

• App Engine spawns a new instance to handle request-5• request-5 is a loading request; request-5 must wait for

instance-2 to fully initialize before being processed

Page 23: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

• instance-2 finally finishes initializing and can now handle requests alongside instance-1

Page 24: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

Loading requests make users wait!

Introducing warm-up requests:• Introduced in Google App Engine v1.4.0• Initialize instances ahead of time so that live requests

do not initiate new instances• On by default• Not always called for every new instance (e.g. the very

1st instance)

Page 25: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

Letʼs replay the previous scenario with warm-up requests. • A single instance handling requests• App Engine sees that instance-1ʼs request queue is

getting overloaded, so...

Page 26: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

• Before any more requests arrive, App Engine sends a warm-up request to initialize a new instance

Page 27: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

• instance-2 finishes initializing and is ready to handle requests alongside instance-1

Page 28: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

• A new requests comes in• instance-2 is ready to handle request-5 right away• request-5 is not a loading request this time

Page 29: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

Fast-forward a few seconds. request-1, 2, and 5 have been processed. • instance-2 is idle and instance-1ʼs queue is not full, so...

Page 30: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

• App Engine scales down and drops instance-2 because it is no longer needed

Page 31: Moving complex enterprise ecommerce systems to the cloud

How App Engine Automatically Scales

Introducing Always-On Instances:• Always-On instances remain running even with no traffic • Minimizes impact of loading requests• A premium feature (i.e. costs a bit more)

Page 32: Moving complex enterprise ecommerce systems to the cloud

Topics

• Challenges with Restricted Classes• How App Engine Automatically Scales• Performance, Performance, Performance• Migrating the Persistence Layer

Page 33: Moving complex enterprise ecommerce systems to the cloud

Performance Tools - AppStats

• AppStats• A servlet filter that measures the performance of each

request

Page 34: Moving complex enterprise ecommerce systems to the cloud

Performance - Loading Deadline

• Recall that any request has the potential to be a loading request

Page 35: Moving complex enterprise ecommerce systems to the cloud

Performance - Request Deadline

• Still need to handle actual request in the remaining time after loading application

• After 60 seconds, a runtime exception will be thrown and the requests will be dropped

Page 36: Moving complex enterprise ecommerce systems to the cloud

Performance - Optimizing

• Loading Request time = Start-Up time + Request time• To thrive on App Engine, request performance and start-

up performance must be optimized together

OptimizeStart-Up

OptimizeRequests

Page 37: Moving complex enterprise ecommerce systems to the cloud

Performance - Optimizing Start-Up

How do you optimize start-up times?

Page 38: Moving complex enterprise ecommerce systems to the cloud

Performance - Optimizing Start-Up

How do you optimize start-up times?

Do Less

Page 39: Moving complex enterprise ecommerce systems to the cloud

Performance - Optimizing Start-Up

Do less at start-up:• In our application half the start up time was being

consumed with classloading• Amount of classloading is application/framework specific• We were loading more classes than expected• Use -verbose:class• Classpath scanning is slow• Use static configuration instead of classpath scanning• Generate configuration at build

Page 40: Moving complex enterprise ecommerce systems to the cloud

Performance - Optimizing Page Loads

• Serve resources from the WAR statically

Before: After:

Page 41: Moving complex enterprise ecommerce systems to the cloud

Performance - Optimizing Page Loads

• App Engine provides memcache service• Cache is shared across instances

• Best effort cache• In our application we gained performance by caching

Spring Remote calls

Page 42: Moving complex enterprise ecommerce systems to the cloud

Topics

• Challenges with Restricted Classes• How App Engine Automatically Scales• Performance, Performance, Performance• Migrating the Persistence Layer

Page 43: Moving complex enterprise ecommerce systems to the cloud

Migrating the Persistence Layer

• Google App Engineʼs persistence layer is Datastore• Datastore is a non-relational database• Most enterprise applications use a relational database• Non-relational databases donʼt have tables

SQL Table: Datastore (abstract):

Page 44: Moving complex enterprise ecommerce systems to the cloud

Migrating the Persistence Layer

• Transaction boundary in Datastore is very different• Can only perform transaction around entity groups• Each entity has a parent entity• An entity group is a tree of entities

Page 45: Moving complex enterprise ecommerce systems to the cloud

Migrating the Persistence Layer

• Existing domain model unlikely to work in Datastore• Different storage structure• Different transaction model• Different tools/framework

What do we do?

Page 46: Moving complex enterprise ecommerce systems to the cloud

Migrating the Persistence Layer

• Existing domain model unlikely to work in Datastore• Different storage structure• Different transaction model• Different tools/framework

What do we do?

Run Away?

Page 47: Moving complex enterprise ecommerce systems to the cloud

Migrating the Persistence Layer

• Datastore is designed to scale with the App Engine cloud• Entities are far easier to cache• Fetches are small and focused• No more fetch group hell• The data and transaction model force cleaner domain

models• More flexible than tables• Can have different properties on the same “type” of

entities• Focus on smaller transactions• Alternatively, use Google Cloud SQL

Page 48: Moving complex enterprise ecommerce systems to the cloud

Letʼs Recap

• Elastic Path is a flexible Java ecommerce platform• Google App Engine is a true cloud platform that

supports Java web applications• App Engineʼs constraints can be liberating• JRE Class restrictions forced one to implement

workarounds with App Engine services• Automatic scalability is achieved with dynamic

instances• App Engine imposes strict performance requirements

on your apps• The Datastore is a non-relational DB that forces one to

untangle the domain model

Page 49: Moving complex enterprise ecommerce systems to the cloud

Was the Migration Worth It?

Page 50: Moving complex enterprise ecommerce systems to the cloud

Was the Migration Worth It?

For us, yes!

Page 51: Moving complex enterprise ecommerce systems to the cloud

Was the Migration Worth It? - Yes!

• Automatic scalability• App Engineʼs restrictions forced us to rethink and

improve our applicationʼs design• Deployments to App Engine are flexible and easy• Production environments are easy to replicate for

testing• No more server configuration management• Reduced costs• Frequent Google App Engine releases continue to

introduce cool, useful features

Page 52: Moving complex enterprise ecommerce systems to the cloud

For more information visit:Web www.elasticpath.comBlog www.getelastic.comTwitter @elasticpath

Thank you.Any Questions?

Page 53: Moving complex enterprise ecommerce systems to the cloud

Additional Resources• Google App Engine homepage: http://code.google.com/appengine/• Maven plugin for Google App Engine: http://code.google.com/p/maven-gae-plugin/• Will It Play In App Engine - lists the level of compatibility of various Java technologies and

App Engine: http://code.google.com/p/googleappengine/wiki/WillItPlayInJava• ESXX - Custom HttpClient 4 URLFetch connection manager: http://esxx.blogspot.com/

2009/06/using-apaches-httpclient-on-google-app.html