32
FFFast Drupal backend No kidding! Pavel Prischepa 1

FFFast Drupal backend No kidding!

Embed Size (px)

Citation preview

Page 1: FFFast Drupal backend No kidding!

FFFast Drupal backend

No kidding!

Pavel Prischepa

1

Page 2: FFFast Drupal backend No kidding!

5 years of work with Drupal (and Drupal only) on an international level • Development • Project management • Drupal PR, promotion • Drupal audit • Consulting

Pavel Prischepa

Partner at i20 Group CEO at DrupalJedi

2

Page 3: FFFast Drupal backend No kidding!

Is Drupal fast?

Browser Cache layer Drupal

3

Page 4: FFFast Drupal backend No kidding!

Real project• 5 000 000 nodes

• 1 000 000 unique visitors per day

• 0,4 seconds per page

• Cache: MongoDB, Redis, NginX, Varnish

• Dynamic blocks: ESI, AJAX

4

Page 5: FFFast Drupal backend No kidding!

Drupal as backend

DrupalSingle-page application

Mobile application

Web sites

5

Page 6: FFFast Drupal backend No kidding!

Drupal as backend

• DRUPAL_BOOTSTRAP_FULL for each request

• 30-100 database queries per request

• Slow server response

6

Page 7: FFFast Drupal backend No kidding!

Silk Paints: mobile application

for drawing

7

Page 8: FFFast Drupal backend No kidding!

Silk Paints

• Users draw paintings, save them to server

• Backend on Drupal (Services)

• 500 000 users

• 5-20 requests per second

8

Page 9: FFFast Drupal backend No kidding!

9

Page 10: FFFast Drupal backend No kidding!

Silk Paints: launch of iOS version

• Likes

• Friend lists

• Pictures moderation

• 50-100 requests per second

10

Page 11: FFFast Drupal backend No kidding!

11

Page 12: FFFast Drupal backend No kidding!

Looking for an alternative to Drupal

• Node.js

• Python

• Zend

12

Page 13: FFFast Drupal backend No kidding!

One does not simply use a new framework

• Change production process

• Train / hire people

• “Nabit’ shishki”

• Meanwhile...project is uncontrollable

13

Page 14: FFFast Drupal backend No kidding!

Back to Drupal

14

Page 15: FFFast Drupal backend No kidding!

Back to Drupal• Coding standards

• Config

• DB integration

• Cache

• Modules

• Design, Develop, Testing, Deploy processes

15

Page 16: FFFast Drupal backend No kidding!

Запрос

Back to Drupal

Drupal

Worker

Queue Worker

WorkerQuick response

Tasks are processed in background

16

Page 17: FFFast Drupal backend No kidding!

Запрос

Back to Drupal

Drupal Module JS

Drush Daemon API

Drupal Queue API

Drush Daemon API

Drush Daemon API

17

Page 18: FFFast Drupal backend No kidding!

Silk Paints: result• 50 requests per second

• 5-10 requests to MySQL per request

• Response time less than 1 second

• Savings on development and support

• Predictability of development

18

Page 19: FFFast Drupal backend No kidding!

Drupal as backend Best practice

19

Page 20: FFFast Drupal backend No kidding!

Application architecture

• Service Oriented Architecture (SOA)

• Queue service (middleware)

20

Page 21: FFFast Drupal backend No kidding!

Queue service

Module 1

Drupal

Module 2

Core, Contrib modules

21

Page 22: FFFast Drupal backend No kidding!

Queue service

Service (based on Module 1)

Drupal Node.js Python

Drupal

Module 2Redis

as a Lock storage

Core, Contrib modules

External services

22

Page 23: FFFast Drupal backend No kidding!

Queue

Worker 1

Producer Worker 2

Worker 3

Work queues (worker per task)

23

Page 24: FFFast Drupal backend No kidding!

Queue

Subscriber 1

PublisherSubscriber 2

Subscriber 3

Publish / subscribe (one message for all subscribers)

24

Page 25: FFFast Drupal backend No kidding!

Queue Task

Producer

RPC

Queue Result

Worker Producer

Worker

Receive result

Create task

25

Producer Worker

Page 26: FFFast Drupal backend No kidding!

Best practice What else?

26

Page 27: FFFast Drupal backend No kidding!

Degradation of functionality

• If load increases, non-critical functionality could be disabled

• Several cases for disabling

• Approach allows pass the peak load successfully

27

Page 28: FFFast Drupal backend No kidding!

Cache

• Application should work perfectly without cache

• Cache invalidation scheme

• “Cold cache” problem

• Efficient of cache using (hit/miss correlation)

28

Page 29: FFFast Drupal backend No kidding!

Database• Take care of database

• Denormalize it!

• Check indexes

• Do not add other databases beforehand (like MongoDB)

• Migrate to Postgres? (…, NoSQL, memory storage)

29

Page 30: FFFast Drupal backend No kidding!

Database replica, partition, sharding

CAP Theorem:

Consistency Availability Partition tolerance

30

Page 31: FFFast Drupal backend No kidding!

The most important

• The main causes of low performance - “krivie ruki”

• Use technologies that you know well

• Remember about business

• Optimize only what prevents sells

31

Page 32: FFFast Drupal backend No kidding!

Thank you!

Pavel Prischepa

CEO at DrupalJedi [email protected]

32