OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application...

37
OSGi Building LinkedIn's Next Generation Architecture with OSGI Yan Pujante Distinguished Software Engineer Member of the Founding Team @ LinkedIn [email protected] http://www.linkedin.com/in/yan Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 1

Transcript of OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application...

Page 1: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

OSGiBuilding LinkedIn's Next Generation Architecture with OSGI

Yan PujanteDistinguished Software Engineer

Member of the Founding Team @ LinkedIn

[email protected]

http://www.linkedin.com/in/yan

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 1

Page 2: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

BackgroundLinkedIn created in 03/2003

close to 30M membersprofitable with 5 revenue linesHQ in Mountain View (400 employees)

Technologies2 datacenters (~ 600 machines)SOA, java, tomcat, spring framework, http, Oracle, MySQL, servlets, jsp, graph, OSGi...

dev on MacOS X, prod on Solaris

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 2

Page 3: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

ChallengesGrowing engineering team on a monolithic code base (still modular)

Growing product team wanting more and more feature, faster

Growing operations team deploying more and more servers

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 3

Page 4: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Back-EndFront-End

tomcat

webapp

1

2

3

N4

Pjetty (1)

webapp

X

webapp

Z

webapp

Y

jetty (2)

webapp

M

webapp

N

webapp

R

Challenges (SOA in dev)

Front-end: many BL services in one webapp (in tomcat)

Back-end: many wars in 5 containers (jetty) with 1 service per war

Note that prod and dev are different

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 4

Page 5: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Container Challenge1 war with N services

does not scale for dev (conflicts, monolithic...)

N wars with 1 service does not scale from a container point of view (no shared jars)• Can add containers but only 12Gb of RAM :(

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 5

Page 6: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Challenges (SOA in prod)Upgrading back-end service to new version requires downtime

Hardware LB does not account for version

Upgrading front-end service to new version requires redeploy

N services in 1 war

Adding new back-end service painfullots of manual configuration (LB, front-end...)

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 6

Page 7: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Solution: OSGiBelief that OSGi is one of the tools that will help us address those challenges

Why OSGi?

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 7

Page 8: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

OSGi introOSGi means “Open Services Gateway initiative”OSGi is a spec with several implementations

Equinox (eclipse!)KnoplerfishFelix (Apache)

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 8

Page 9: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

OSGi intro (cont.)OSGi has some very good properties

Smart class loading => multiple versions jars okHighly dynamic => deploy / undeploy built inServices registryHighly extensible / configurable

OSGi bundle = Jar File with OSGi manifests

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 9

Page 10: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

OSGi bundleSpecification-Title: Colorado Software Summit 2008 Hello Wolrd ClientBundle-Activator: com.linkedin.colorado.helloworld.client.HelloWorldClientActivatorImport-Package: com.linkedin.colorado.helloworld.api;version="[1.0.0,1.0.1)", com.linkedin.colorado.helloworld.client;version="[1.0.0,1.0.1)", org.osgi.framework;version="[1.4.0,1.4.1)"Export-Package: com.linkedin.colorado.helloworld.client;version="1.0.0"Bundle-Version: 1.0.0Bundle-Name: colorado-helloworld-clientBundle-ManifestVersion: 2Bundle-SymbolicName: colorado-helloworld-clientBnd-LastModified: 1224557973403Generated-On: 20081020Tool: Bnd-<unknown version>Implementation-Version: DevBuild

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 10

Page 11: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

BundleActivator

public interface ServletContextListener extends EventListener { void contextInitialized(ServletContextEvent event); void contextDestroyed(ServletContextEvent event);}

In a war: ServletContextListener

web.xml <listener> <listener-class>com.colorado.MyListener</listener-class> </listener>

In a Bundle: BundleActivatorpublic interface BundleActivator { void start(BundleContext bundleContext) throws Exception; void stop(BundleContext bundleContext) throws Exception;}

MANIFEST.MFBundle-Activator: com.colorado.MyActivator

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 11

Page 12: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

BundleContextThe bundle context is the entry point:

registerService / getServiceReference => to register / get services from registryaddBundleListener / addServiceListener => to listens / extends the frameworkeven installBundle !... and more

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 12

Page 13: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

DemoEquinox demo... stay tuned...

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 13

Page 14: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Web ContainerServices exported with Spring/RPCServices in same war can see each otherShare the jars

VM

WEB Container

WARJARs

Services

SpringRPC

HTTP

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 14

Page 15: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

VM

WEB Container

JARs

Services

SpringRPC

HTTP

JARs

Services

SpringRPC

Web Container

Cannot share jarsCannot talk directly

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 15

Page 16: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

VM

OSGi Container

Service Registry

Bundles

OSGi containerBundles (jars) sharedServices sharedDynamic replacement of bundles

OSGi solves the container challenge

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 16

Page 17: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Distributed OSGiOSGi is currently container centric

Next version (4.2) will introduce distributed OSGi

What do we do in the meantime ?

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 17

Page 18: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

LinkedIn distributed OSGi

Service ‘red’ talks to service ‘green’ (local)

What happens if we move ‘green’ to a different container ?

Service Registry

VMC1

Service Registry

Bundles

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 18

Page 19: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

VMC3

VMC2

Service Registry

VMC1

Service Registry

Bundles

Bundles

Bundles

Service Registry

LinkedIn distributed OSGi

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 19

Page 20: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

VMC3

VMC2

VMC1

Service Registry

Bundles

2

2

Bundles

Bundles

Service Registry

Service Registry

LinkedIn distributed OSGi

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 20

Page 21: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

VMC3

VMC2

VMC1

Service Registry

Bundles

2

2

Bundles

Bundles

Service Registry

Service Registry

3

3

LinkedIn distributed OSGi

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 21

Page 22: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

VMC3

VMC2

VMC1

Service Registry

Bundles

2

2

Bundles

Bundles

Service Registry

Service Registry

3

3

LinkedIn distributed OSGi

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 22

Page 23: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

LinkedIn distributed OSGino more N-1 / 1-N problem

libraries and services can be shared in 1 container (mem. footprint smaller)services shared across containers

transparent location to clientsno more configurations to change when adding/removing/moving services

software load balancermuch more flexible (handle version)

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 23

Page 24: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

LB and version

VMC3

VMC2

VMC1

Service Registry

Bundles

22

Bundles

Bundles

Service Registry

Service Registry

3

3

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 24

Page 25: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Everything is perfect...

...Not reallyOSGi has some problems

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 25

Page 26: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

OSGi problemsOSGi is great, but tooling is not quite there yetNot every lib is a bundleOSGi was designed for embedded devices => using it for server side is recent (but very active)

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 26

Page 27: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

OSGi problemsOSGi is quite low level => but there is some work to ‘hide’ the complexity

spring DM (spring dynamic module)multiple vendors containers• Spring DM Server, Glassfish, Infiniflow

OSGi is container centric, but next version will add distributed OSGi (although no support for LB)

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 27

Page 28: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

OSGi problems (cont.)version management can be nightmarish

Import-Package: com.linkedin.util;version=1.0.0

version=1.0.0 means [1.0.0, )

should use at least: version=[1.0.0,2.0.0)

runtime is dynamic and can result in untested code being executed!

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 28

Page 29: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Runtime version problem

client1 and client2 uses Service 3.0.0Dependencies are ‘loose’: [3.0.0, 4.0.0)

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 29

Page 30: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Runtime version problem

We upgrade client1 and service

client2 starts using green bundles

=> Most likely untested

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 30

Page 31: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Runtime version solutions ?

A solution is to lock version: [1.0.0,1.0.0] => no slack[1.0.0,1.0.1) => tiny bit of slack for emergency mode

Does it really work ? spring 2.5.5 imports hibernate version [3.1, )

Can OSGi even resolve with everything locked down ?

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 31

Page 32: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Runtime version problem

With maximal lock-down, client2 cannot use the new service

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 32

Page 33: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Runtime version solutions ?

Services cannot talk to each other directly => need serialization for backward compatible services (dynamic proxy)

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 33

Page 34: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Despite problems...

...OSGi and community moving in the right direction

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 34

Page 35: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

Where are we ?Bundle repository (big amount of work... in progress)Use ivy/bnd for generating bundlesEvaluating container

Infiniflow (from Paremus) most likely the one

LinkedIn spring / SCA to deploy composites

Work on the load balancer/distribution (in progress)Work on tooling / build integration (Sigil from Paremus)Much much more to do...

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 35

Page 36: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

ConclusionUsing OSGi... definitely!But we do not want application developers to have to deal with it.

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 36

Page 37: OSGi - Software · PDF fileConclusion Using OSGi... definitely! But we do not want application developers to have to deal with it. ... Title: PujanteOSGi.key Author: Peggy Kovsky Created

More informationCheck my posts on the LinkedIn blog (OSGi series). More to come...

Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, LinkedIn

Yan Pujante — OSGi: Building LinkedIn's Next Generation Architecture with OSGI Slide 37