40
Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 1 von 40 12th Plone Conference Bristol, UK, 2014 Big Fat Fast Plone Scale Up, Speed Up Jens W. Klein twitter: @yenzenz [email protected] 30.10.2014 http://kleinundpartner.at

Big Fat FastPlone - Scale up, speed up

Embed Size (px)

Citation preview

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 1 von 40

12th Plone ConferenceBristol, UK, 2014

Big Fat Fast Plone Scale Up, Speed Up

Jens W. Klein twitter: @yenzenz [email protected]

30.10.2014 http://kleinundpartner.at

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 2 von 40

I'am ...

● located in Innsbruck, Tyrol, Austria● doing Plone since v.1.0● a consultant, developer, open source evangelist● owner of Klein & Partner KG, co-founder and

member of BlueDynamics Alliance

Ad:Alpine City Sprint at Innsbruck

January 20th to 25th 2015 – registration at

http://www.coactivate.org/projects/alpinecitysprint2015

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 3 von 40

Problem

● Default Plone is not that fast● Scales great horizontally (add machines)● Still bottlenecks

– primary loading stuff from ZODB

– rendering of sites

– searching information

– third party services: ldap, crm, sap-bc, ...

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 4 von 40

You have to knowyour knobs and handles.

Juliett U-461

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 5 von 40

3 different customers(1)

● Niederösterreich Kulturwirtschaft (NOEKU)● central service for several cultural institutions in

Lower Austria● over 30 Plone Sites (including e-ticketing)● hi-availibility on low-to-mid budget● self hosted on hardware, ● VM's with KVM, HA with Pacemaker, CRM, DRBD

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 6 von 40

Noeku in Detail

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 7 von 40

3 different customers(2)

● Zumtobel Group AG● Internationally leading supplier of integral

lighting solutions● Brand specific international product Portals● Customer Extranets, B2B e-shop● Hosting on dedicated and managed VM's and

NAS storage

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 8 von 40

3 different customers(3)

● HTU Graz● general students' representative body, serves

as the students' government, at the University of Graz

● One plone site with several subsites (lineage)● Lots of students looking at it = peak-load● One virtual machine on overloaded host

= not enough resources● Low-budget

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 9 von 40

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 10 von 40

Data Flow in Ploneor

the Publishing ChainDatabase

Client ConnectionPool

Plone 1..n

CachingProxy

LoadBalancer

Webserver

Webbrowser

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 11 von 40

Data Flow in Ploneor

the Publishing ChainDatabase

Client ConnectionPool

Plone 1..n

CachingProxy

LoadBalancer

Webserver

Webbrowser

ZEO-Server orPostgreSQL, plusBlobstorage (NFS, NAS)

Different ZEO Storage Adapters

HAProxy orPound

Varnish(what else?)

NGINX

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 12 von 40

Data Flow in Ploneor

the Publishing ChainDatabase

Client ConnectionPool

Plone 1..n

CachingProxy

LoadBalancer

Webserver

Webbrowser

ZEO-Server orPostgreSQL, plusBlobstorage (NFS, NAS)

Different ZEO Storage Adapters

HAProxy orPound

Varnish(what else?)

NGINX

MemcachedLDAPOther third part services

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 13 von 40

Data Flow in Ploneor

the Publishing ChainDatabase

Client ConnectionPool

Plone 1..n

CachingProxy

LoadBalancer

Webserver

Webbrowser

ZEO-Server orPostgreSQL, plusBlobstorage (NFS, NAS)

Different ZEO Storage Adapters

HAProxy orPound

Varnish(what else?)

NGINX

MemcachedLDAPOther third part services

Consider also:CPU CoresUsed RAM/ Diskcache ratioIO network and disk...

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 14 von 40

Tools know them!

● install Munin on every node and monitor all you can.

● fio is simple powerful to get measures● read how linux manages disk/RAM● know your hardware and your VMs (if any)

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 15 von 40

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 16 von 40

Database Level

● NOEKU: ZEO-Server + BlobStorage, both replicated with DRBD on own self-managed VM

● Zumtobel: RelStorage on PostgreSQL and Blobs from NAS over NFS

● HTU Graz: RelStorage on PostgreSQL, all on one machine.

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 17 von 40

Never store blobs in ZODB

Use blobstorage!

(check your code and adons!)

First things first

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 18 von 40

Classical ZEO Server+Blobstorage

● Using classical ZEO-server + blobstorage– ensure a fast IO to HDD or NAS

– have enough RAM for disk buffering

● Blobstorage on NFS/NAS:– shared blobs and mount on each node

– mount NAS/NFS read-only on webserver node and use collective.xsendfile (X-HTTP-Accel)

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 19 von 40

RelStorage + Blobstorage

● Never store blobs in SQL DB (same as with ZODB, see slide before)

● Do not use MySQL if you can avoid it● Configure your SQL DB properly, defaults are

not enough!● Ensure a sane disk-/storage-IO (on Vms this is a

common bottleneck). ● Have RAM left for OS-level disk-caching.

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 20 von 40

Connections PoolZEO- vs. RelStorage Adapter

● ZEO-Server pushes invalidations to client

● Disk cache of pickled objects per Zope instance

● RAM-cache of unpickled objects per connection

● ZEO-Client polls for invalidated objects

● Memcached of pickled objects shared between Zope instances on one machine

● RAM-cache of unpickled objects per connection

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 21 von 40

Database-/ Client- Configurations (1)

● NOEKU (ZEO)– 30 sites with different sizes

– 2 (rare: 4) instances, each 2 threads

– RAM cache ~750 - 20000 objects – depending on the site – no disk cache

– ZEO-Server with DRBD and failover (works with Plone >=4) on own Virtual Maschine

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 22 von 40

Database-/ Client- Configurations (2)

● Zumtobel (RelStorage, history free)– Different setups for different kinds of sites!

– Always 2 VMs for, because of easier maintainability

– 16 instances plus some worker-instances (async import, zipfile creation, ...)

– each 2 or 4 threads

– RAM cache 30000 or 100000 objects

– Memcached as shared connection cache

– relstorage_packer (search on pypi)

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 23 von 40

Database-/ Client- Configurations (3)

● HTU (RelStorage, history free)– 6 instances, each 1 thread

– RAM cache 30000 objects

– Memcached as shared connection cache

– Poll interval 120 sec

– Blobstorage shared folder on same maschine

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 24 von 40

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 25 von 40

All between Request and Response has to be fast

REQUEST

(what Plone does)

RESPONSE

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 26 von 40

Plone Configuration

● Turn off: debug mode, verbose security, logging, deprecation warnings, …

● Configure plone.app.caching, even if you do not plan to use varnish! → browser caches too!

● multiple plone instances: use memcached instead of classic ramcache

● install jarn.checkinterval and tweak the checkinterval of your instance in your live buildout.

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 27 von 40

Custom Code andSomeones Add-On

● know plone.memoize, use it● never calculate/search twice● cache searched/ prepared data and/or rendered

pages or snippets ● again: never store blobs in ZODB.● use the catalog● dont overuse metadata

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 28 von 40

Write conflicts

● Happens >90% of time at catalog● Use collective.solr/ collective.indexing● Reduce time of the transaction

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 29 von 40

Lots of objects?

● large site with several 100 thousands of content items (and even more objects in ZODB)?

● Catalog queries are slow?● Use an own mount point with own caches for

the catalog● if that does not help, use collective.solr

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 30 von 40

Archetypes vs. Dexterity

● in Archetypes avoid to "wake up" (read: load from DB) the object, ask the catalog and use metadata

● in Dexterity its some times cheaper to wake up the object:

– If objects are small.

– And if you iterate over a folder or subtree

– Or if adding lots of metadata to the catalog would be needed.

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 31 von 40

Using Webservices, LDAP, other Databases

● Talking to external systems over network is slow.

● Cache whats possible → plone.memoize● Measure the external system!● How fail safe are the services? ● Does your addon/custom code behaves nicely if

the service fails?

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 32 von 40

In case of serious performance trouble

● Measure! – Munin (base system parameters),

– Fio,

– collective.traceview

– Good old friend Products.ZopeProfiler

– haufe.requestmonitoring, Products.LongRequestLogger

● Do not change more than one parameter at once,

● measure again.

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 33 von 40

plone.app.caching

● Caching is essential in order to serve hi-traffic.● On Peak load a site can be faster (!) than on

normal traffic.● Varnish + plone.app.caching are our superheros● Default settings are good for default sites● Custom Addons with own types and

templates needs extra configuration for each type and template:

– Do this! Calculate time for this task, its some work!

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 34 von 40

Micro-Caching

● On hi traffic introduce a new caching rule for one two five minute caches

● It speeds up a public facing site really good!

● Apply this rule to all types/ templates youre expecting to be hit

● This means a small delay for content editors between save and live.

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 35 von 40

Microcachingused at...

● Zumtobel– Extranet on group level

– Portal for all anonymous

● HTU Graz– For all anonymous

● Bunch of other sites– Mostly anonymous access

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 36 von 40

Load Balancer

● Pound → tiny, simple, stable, old, but difficult to get measurements out of it.

● HAProxy → not that simple, complex configuration, newer, nice WebUI for stats

● Point same request type to same instance– Stick to session (public site)

– Stick to User (intranet)

– Stick to Group/ other vector (customer extranet)

● Group Instances for editors/ anonymous

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 37 von 40

Webserver

● NGINX – others possible, but more difficult to configure

● Set the proxy_* to recommended values● Consider configuring direct blob delivery (using

collective.xsendfile)– collective.xsendfile needs some love to work fine

with dexterity and plone.app.imaging (deliver more variants) – any takers?

● Mostly it works fine OOTB

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 38 von 40

*Cat Image (Bobcat by Markus Wollny) CC BY-NC-SA2.0 License

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 39 von 40

Further Reading

● Plone Documentation Chapter„Performance and tuning“

http://docs.plone.org/manage/deploying/testing_tuning/performance/index.html

Text: Creative Commons Namensnennung-Keine kommerzielle Nutzung- Keine Bearbeitung 3.0 Österreich Lizenz. 40 von 40

Questions?