SlideShare a Scribd company logo
1 of 155
Live on
Stage
  Dominik Jungowski - May 14, 2010




   Live on Stage - Dominik Jungowski
Agenda




                                    2

Live on Stage - Dominik Jungowski
Agenda
‣ What is Staging?




                                                    2

                Live on Stage - Dominik Jungowski
Agenda
‣ What is Staging?


‣ Reasons for Staging




                                                    2

                Live on Stage - Dominik Jungowski
Agenda
‣ What is Staging?


‣ Reasons for Staging


‣ Implementation




                                                    2

                Live on Stage - Dominik Jungowski
Agenda
‣ What is Staging?


‣ Reasons for Staging


‣ Implementation


‣ Adding a staging layer


                                                    2

                Live on Stage - Dominik Jungowski
Agenda
‣ What is Staging?


‣ Reasons for Staging


‣ Implementation


‣ Adding a staging layer


‣ Problems and Solutions
                                                    2

                Live on Stage - Dominik Jungowski
About me




                                    3

Live on Stage - Dominik Jungowski
About me
‣ 25 years old




                                                     3

                 Live on Stage - Dominik Jungowski
About me
‣ 25 years old
‣ Employed at CHIP Xonio Online GmbH




                                                     3

                 Live on Stage - Dominik Jungowski
About me
‣ 25 years old
‣ Employed at CHIP Xonio Online GmbH
  ➡ www.chip.de




                                                      3

                  Live on Stage - Dominik Jungowski
About me
‣ 25 years old
‣ Employed at CHIP Xonio Online GmbH
  ➡ www.chip.de

  ➡ download.chip.eu




                                                      3

                  Live on Stage - Dominik Jungowski
About me
‣ 25 years old
‣ Employed at CHIP Xonio Online GmbH
  ➡ www.chip.de

  ➡ download.chip.eu

‣ ScrumMaster and Developer at price
    comparison




                                                      3

                  Live on Stage - Dominik Jungowski
About me
‣ 25 years old
‣ Employed at CHIP Xonio Online GmbH
  ➡ www.chip.de

  ➡ download.chip.eu

‣ ScrumMaster and Developer at price
    comparison
‣ Part - time studies in Psychology at distance
    university FernUni Hagen

                                                      3

                  Live on Stage - Dominik Jungowski
What is
staging?

  Live on Stage - Dominik Jungowski
What is Staging?
  Usual Database Design:




                                         5

     Live on Stage - Dominik Jungowski
What is Staging?
  Usual Database Design:


      Databa



                                         5

     Live on Stage - Dominik Jungowski
What is Staging?
    Usual Database Design:


          Databa


Website

                                           5

       Live on Stage - Dominik Jungowski
What is Staging?
    Usual Database Design:


          Databa


Website

                                           5

       Live on Stage - Dominik Jungowski
What is Staging?
    Usual Database Design:


          Databa


Website                      Admin

                                           5

       Live on Stage - Dominik Jungowski
What is Staging?
    Usual Database Design:


          Databa


Website                      Admin

                                           5

       Live on Stage - Dominik Jungowski
What is Staging?
 Staging Database Design:




                                         6

     Live on Stage - Dominik Jungowski
What is Staging?
   Staging Database Design:


Databa




                                           6

       Live on Stage - Dominik Jungowski
What is Staging?
    Staging Database Design:


Databa


Website

                                              6

          Live on Stage - Dominik Jungowski
What is Staging?
    Staging Database Design:


Databa


Website

                                              6

          Live on Stage - Dominik Jungowski
What is Staging?
    Staging Database Design:


Databa                          Databa


Website

                                              6

          Live on Stage - Dominik Jungowski
What is Staging?
    Staging Database Design:


Databa                          Databa


Website                             Admin

                                              6

          Live on Stage - Dominik Jungowski
What is Staging?
    Staging Database Design:


Databa                          Databa


Website                             Admin

                                              6

          Live on Stage - Dominik Jungowski
What is Staging?
    Staging Database Design:


Databa                          Databa


Website                             Admin

                                              6

          Live on Stage - Dominik Jungowski
What is Staging?
    Staging Database Design:


Databa             Sync         Databa


Website                             Admin

                                              6

          Live on Stage - Dominik Jungowski
Reasons for
staging

   Live on Stage - Dominik Jungowski
Reasons for Staging




                                         8

     Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Security




                                                 8

             Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Security
  ➡ no sensitive data on live system




                                                     8

                 Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Security
  ➡ no sensitive data on live system

  ➡ only the essential data is synced




                                                     8

                 Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Security
  ➡ no sensitive data on live system

  ➡ only the essential data is synced


‣ Quality




                                                     8

                 Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Security
  ➡ no sensitive data on live system

  ➡ only the essential data is synced


‣ Quality
  ➡ no changes directly on live system




                                                     8

                 Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Security
  ➡ no sensitive data on live system

  ➡ only the essential data is synced


‣ Quality
  ➡ no changes directly on live system

  ➡ more time to prevent corruption/errors on live
      system (user errors, broken imports, etc.)


                                                     8

                 Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Performance




                                                    9

                Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Performance
  ➡ Normalized data on staging database




                                                    9

                Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Performance
  ➡ Normalized data on staging database

  ➡ Performance optimized / flat data on live database




                                                     9

                 Live on Stage - Dominik Jungowski
Reasons for Staging
‣ Performance
  ➡ Normalized data on staging database

  ➡ Performance optimized / flat data on live database

  ➡ no constraints on live system possible




                                                     9

                 Live on Stage - Dominik Jungowski
Implementat
ion

  Live on Stage - Dominik Jungowski
Implementation




                                       11

   Live on Stage - Dominik Jungowski
Implementation
‣ Data is synced




                                                       11

                   Live on Stage - Dominik Jungowski
Implementation
‣ Data is synced
  ➡ some kind of status flag in staging db is needed




                                                       11

                   Live on Stage - Dominik Jungowski
Implementation
‣ Data is synced
  ➡ some kind of status flag in staging db is needed

‣ Status needed for




                                                       11

                   Live on Stage - Dominik Jungowski
Implementation
‣ Data is synced
  ➡ some kind of status flag in staging db is needed

‣ Status needed for
  ➡ Changed data




                                                       11

                   Live on Stage - Dominik Jungowski
Implementation
‣ Data is synced
  ➡ some kind of status flag in staging db is needed

‣ Status needed for
  ➡ Changed data

  ➡ Unchanged data




                                                       11

                   Live on Stage - Dominik Jungowski
Implementation
‣ Data is synced
  ➡ some kind of status flag in staging db is needed

‣ Status needed for
  ➡ Changed data

  ➡ Unchanged data

  ➡ Deleted data on staging, but not on live system




                                                       11

                   Live on Stage - Dominik Jungowski
Implementation
‣ Data is synced
  ➡ some kind of status flag in staging db is needed

‣ Status needed for
  ➡ Changed data

  ➡ Unchanged data

  ➡ Deleted data on staging, but not on live system

‣ Maybe useful


                                                       11

                   Live on Stage - Dominik Jungowski
Implementation
‣ Data is synced
  ➡ some kind of status flag in staging db is needed

‣ Status needed for
  ➡ Changed data

  ➡ Unchanged data

  ➡ Deleted data on staging, but not on live system

‣ Maybe useful
  ➡ Deleted on live system

                                                       11

                   Live on Stage - Dominik Jungowski
Implementation
  The Status - Cycle




                                       12

   Live on Stage - Dominik Jungowski
Implementation
  The Status - Cycle




           Import




                                       12

   Live on Stage - Dominik Jungowski
Implementation
  The Status - Cycle




           Import




                                       12

   Live on Stage - Dominik Jungowski
Implementation
        The Status - Cycle


 ne
    w   or
             ch
               an
                 ge
                    dd
                      ata

                         Import




                                                 12

             Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata

                                  Import




                                                          12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata

                                  Import




                                                          12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                  Import




                                                          12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                  Import




  No
change
  [0]

                                                          12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                  Import




  No
change
  [0]

                                                          12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                  Import
                                           rem
                                              ov
                                                ed
                                                     da
                                                       ta


  No
change
  [0]

                                                            12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                  Import
                                           rem
                                              ov
                                                ed
                                                     da
                                                       ta


  No                                                        Changed
change                                                      Deleted
  [0]                                                         [3]

                                                                      12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                  Import
                                           rem
                                              ov
                                                ed
                                                     da
                                                       ta


  No                                                        Changed
change                                                      Deleted
  [0]                                                         [3]

                                                                      12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                  Import
                                           rem
                                              ov
                                                ed
                                                     da
                                                       ta


  No                                                        Changed
change                                                      Deleted
  [0]                                                         [3]

                                                                      12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed
  [1]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                                               Sync
                                  Import
                                           rem
                                              ov
                                                ed
                                                     da
                                                       ta


  No                                                        Changed
change                                                      Deleted
  [0]                                                         [3]

                                                                      12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed                                                     Deleted
  [1]                                                         [2]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                                                Sync
                                  Import
                                           rem
                                              ov
                                                ed
                                                     da
                                                       ta


  No                                                        Changed
change                                                      Deleted
  [0]                                                         [3]

                                                                       12

                      Live on Stage - Dominik Jungowski
Implementation
                 The Status - Cycle

Changed                                                     Deleted
  [1]                                                         [2]
          ne
             w   or
                      ch
                        an
                          ge
                             dd
                               ata
Sync




                                                                Sync
                                  Import
                                           rem
                                              ov
                                                ed
                                                     da
                                                       ta


  No                                                        Changed
change                                                      Deleted
  [0]                                                         [3]

                                                                       12

                      Live on Stage - Dominik Jungowski
Implementation



 Why 0, 1, 2,
 3?

   Live on Stage - Dominik Jungowski
Implementation



    Why 0, 1, 2,
    3?
Let‘s take a look at the binary
numbers!



         Live on Stage - Dominik Jungowski
Implementation




                                       14

   Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]




                                             14

         Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                    =




                                             14

         Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                    =                 0000




                                             14

         Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]




                                              14

          Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]                =




                                              14

          Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]                =                 0001




                                              14

          Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]                =                 0001

Deleted
  [2]




                                              14

          Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]                =                 0001

Deleted
  [2]                =



                                              14

          Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]                =                 0001

Deleted
  [2]                =                 0010


                                              14

          Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]                =                 0001

Deleted
  [2]                =                 0010
Changed
Deleted
  [3]
                                              14

          Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]                =                 0001

Deleted
  [2]                =                 0010
Changed
Deleted
  [3]
                     =
                                              14

          Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]                =                 0001

Deleted
  [2]                =                 0010
Changed
Deleted
  [3]
                     =                 0011
                                              14

          Live on Stage - Dominik Jungowski
Implementation
  No
change
  [0]
                     =                 0000

Changed
  [1]                =                 0001

Deleted
  [2]                =                 0010
Changed
Deleted
  [3]
                     =                 0011
                                      = 0001 | 0010
                                                      14

          Live on Stage - Dominik Jungowski
Implementation
             Using the binary flags in PHP
class phpDay_Sync
{
   /**
    * Status for changed data
    * Binary: 0001
    */
   const STATUS_CHANGED = 1;

    /**
     * Status for removed data
     * Binary: 0010
     */
    const STATUS_DELETED = 2;

    ...
}
                                                          15

                      Live on Stage - Dominik Jungowski
Implementation
Using the binary flags in PHP




                                          16

      Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker status has changed




                                                         16

                     Live on Stage - Dominik Jungowski
Implementation
           Using the binary flags in PHP
// Speaker status has changed
$speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED;




                                                        16

                    Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker status has changed
$speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED;

// Speaker has been synced to live system




                                                          16

                      Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker status has changed
$speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED;

// Speaker has been synced to live system
$speaker[‘status‘] =




                                                          16

                      Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker status has changed
$speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED;

// Speaker has been synced to live system
$speaker[‘status‘] =
   (phpDay_Sync::STATUS_CHANGED &
   phpDay_Sync::STATUS_DELETED);




                                                          16

                      Live on Stage - Dominik Jungowski
Implementation
               Using the binary flags in PHP
// Speaker status has changed
$speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED;

// Speaker has been synced to live system
$speaker[‘status‘] =
   (phpDay_Sync::STATUS_CHANGED &
   phpDay_Sync::STATUS_DELETED);

//... or easier :-)




                                                          16

                      Live on Stage - Dominik Jungowski
Implementation
             Using the binary flags in PHP
// Speaker status has changed
$speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED;

// Speaker has been synced to live system
$speaker[‘status‘] =
   (phpDay_Sync::STATUS_CHANGED &
   phpDay_Sync::STATUS_DELETED);

//... or easier :-)
$speaker[‘status‘] = 0;




                                                              16

                          Live on Stage - Dominik Jungowski
Implementation
Using the binary flags in PHP




                                          17

      Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker didn‘t show up in import file




                                                          17

                      Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker didn‘t show up in import file
// 0001 | 0010 = 0011




                                                          17

                      Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker didn‘t show up in import file
// 0001 | 0010 = 0011
$speaker[‘status‘] =




                                                          17

                      Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker didn‘t show up in import file
// 0001 | 0010 = 0011
$speaker[‘status‘] =
   (phpDay_Sync::STATUS_CHANGED |
   phpDay_Sync::STATUS_DELETED);




                                                          17

                      Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker didn‘t show up in import file
// 0001 | 0010 = 0011
$speaker[‘status‘] =
   (phpDay_Sync::STATUS_CHANGED |
   phpDay_Sync::STATUS_DELETED);

// Speaker has been deleted on live system




                                                          17

                      Live on Stage - Dominik Jungowski
Implementation
            Using the binary flags in PHP
// Speaker didn‘t show up in import file
// 0001 | 0010 = 0011
$speaker[‘status‘] =
   (phpDay_Sync::STATUS_CHANGED |
   phpDay_Sync::STATUS_DELETED);

// Speaker has been deleted on live system
$speaker[‘status‘] = phpDay_Sync::STATUS_DELETED;




                                                          17

                      Live on Stage - Dominik Jungowski
Binary AND
&    0          1           2            3

0               0           0            0

1    0                      0            1

2    0          0                        2

3    0          1           2
                                             18

     Live on Stage - Dominik Jungowski
Binary AND
&    0          1           2            3
                    0000        0000      0000
0               & 0001      & 0010       & 0011
                = 0000      = 0000       = 0000
         0001                   0001      0001
1    & 0000                 & 0010       & 0011
     = 0000                 = 0000       = 0001
         0010       0010                  0010
2    & 0000     & 0001                   & 0011
     = 0000     = 0000                   = 0010
         0011       0011        0010
3    & 0000     & 0001      & 0011
     = 0000     = 0001      = 0010
                                                  19

     Live on Stage - Dominik Jungowski
Binary OR
|   0          1           2            3

0              1           2            3

1   1                      3            3

2   2          3                        3

3   3          3           3
                                            20

    Live on Stage - Dominik Jungowski
Binary OR
|   0          1           2            3
                   0000        0000      0000
0               | 0001     | 0010       | 0011
               = 0001      = 0010       = 0011
        0001                   0001      0001
1   | 0000                 | 0010       | 0011
    = 0001                 = 0011       = 0011
        0010       0001                  0010
2   | 0000      | 0010                  | 0011
    = 0010     = 0011                   = 0011
        0011       0011        0011
3   | 0000      | 0001     | 0010
    = 0010     = 0011      = 0011
                                                 21

    Live on Stage - Dominik Jungowski
Deleting on live
system
     Status 3 Status 2




       Live on Stage - Dominik Jungowski
Implementation
&   0          1           2            3

0              0           0            0

1   0                      0            1

2   0          0                        2

3   0          1           2
                                            23

    Live on Stage - Dominik Jungowski
Implementation
        ... in PHP




                                       24

   Live on Stage - Dominik Jungowski
Implementation
                            ... in PHP
// We‘ve synced the deleted speaker, status 3 => status 2




                                                            24

                      Live on Stage - Dominik Jungowski
Implementation
                            ... in PHP
// We‘ve synced the deleted speaker, status 3 => status 2
// 0011 & 0010 = 0010




                                                            24

                      Live on Stage - Dominik Jungowski
Implementation
                            ... in PHP
// We‘ve synced the deleted speaker, status 3 => status 2
// 0011 & 0010 = 0010
$speaker[‘status‘] =




                                                            24

                      Live on Stage - Dominik Jungowski
Implementation
                            ... in PHP
// We‘ve synced the deleted speaker, status 3 => status 2
// 0011 & 0010 = 0010
$speaker[‘status‘] =
   ($speaker[‘status‘] & phpDay_Sync::STATUS_DELETED);




                                                            24

                      Live on Stage - Dominik Jungowski
Implementation
                            ... in PHP
// We‘ve synced the deleted speaker, status 3 => status 2
// 0011 & 0010 = 0010
$speaker[‘status‘] =
   ($speaker[‘status‘] & phpDay_Sync::STATUS_DELETED);

// or if you know you will never use more than those 4 status flags:




                                                                      24

                       Live on Stage - Dominik Jungowski
Implementation
                            ... in PHP
// We‘ve synced the deleted speaker, status 3 => status 2
// 0011 & 0010 = 0010
$speaker[‘status‘] =
   ($speaker[‘status‘] & phpDay_Sync::STATUS_DELETED);

// or if you know you will never use more than those 4 status flags:
$speaker[‘status‘] = phpDay_Sync::STATUS_CHANGEDELETED;




                                                                      24

                       Live on Stage - Dominik Jungowski
Implementation
      ... in MySQL




                                       25

   Live on Stage - Dominik Jungowski
Implementation
                          ... in MySQL
// We‘ve synced the deleted speaker, status 3 => status 2
// 0011 & 0010 = 0010
$sql =
   ‘UPDATE speaker SET status = status & ‘ .
   phpDay_Sync::STATUS_DELETED;




                                                            25

                      Live on Stage - Dominik Jungowski
Implementation
                          ... in MySQL
// We‘ve synced the deleted speaker, status 3 => status 2
// 0011 & 0010 = 0010
$sql =
   ‘UPDATE speaker SET status = status & ‘ .
   phpDay_Sync::STATUS_DELETED;
‣ But: Rather slow in MySQL




                                                            25

                      Live on Stage - Dominik Jungowski
Implementation
                          ... in MySQL
// We‘ve synced the deleted speaker, status 3 => status 2
// 0011 & 0010 = 0010
$sql =
   ‘UPDATE speaker SET status = status & ‘ .
   phpDay_Sync::STATUS_DELETED;
‣ But: Rather slow in MySQL
// We‘ve synced the deleted speaker, status 3 => status 2
// 0011 & 0010 = 0010
$status = $speaker->getStatus();
$sql =
   ‘UPDATE speaker SET status = ‘ . ($status &
   phpDay_Sync::STATUS_DELETED);


                                                            25

                      Live on Stage - Dominik Jungowski
Adding a staging
     layer
        Things to consider




    Live on Stage - Dominik Jungowski
Adding a staging layer




                                           27

       Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Distribution of cronjobs: 1 server ➝ 2 servers




                                                    27

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Distribution of cronjobs: 1 server ➝ 2 servers
  ➡ Data you need on live system




                                                    27

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Distribution of cronjobs: 1 server ➝ 2 servers
  ➡ Data you need on live system

  ➡ Data you need on staging system




                                                    27

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Distribution of cronjobs: 1 server ➝ 2 servers
  ➡ Data you need on live system

  ➡ Data you need on staging system

  ➡ Data you need on both systems




                                                    27

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Distribution of cronjobs: 1 server ➝ 2 servers
  ➡ Data you need on live system

  ➡ Data you need on staging system

  ➡ Data you need on both systems

‣ Write down all the cronjobs




                                                    27

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Distribution of cronjobs: 1 server ➝ 2 servers
  ➡ Data you need on live system

  ➡ Data you need on staging system

  ➡ Data you need on both systems

‣ Write down all the cronjobs
‣ Decide where you need them




                                                    27

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Switching live system




                                                    28

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Switching live system




                                    Database
                                     server




                                                    28

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Switching live system



                                    Old database
                                    Database
                                     server




                                                    28

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Switching live system



                                    Old database
                                    Database
                                     server
                                    New (synced)
                                      database




                                                    28

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Switching live system



                                    Old database
                                    Database
  Website                            server
                                    New (synced)
                                      database




                                                    28

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Switching live system



                                    Old database
                                    Database
  Website                            server
                                    New (synced)
                                      database




                                                    28

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Switching live system



                                    Old database
                                    Database
  Website                            server
                                    New (synced)
                                      database




                                                    28

                Live on Stage - Dominik Jungowski
Adding a staging layer
‣ Switching live system



                                    Old database
                                    Database
  Website                            server
                                    New (synced)
                                      database




                                                    28

                Live on Stage - Dominik Jungowski
Problems &
 Solutions

                                     29

 Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity




                                                    30

                Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity




                         Status
                          flag

                                                    30

                Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity


     Read for
       Sync




                         Status
                          flag

                                                    30

                Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity


     Read for
       Sync




                         Status
                          flag

                                                    30

                Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity


     Read for
       Sync
                St
                at
                 us
                     :1




                              Status
                               flag

                                                         30

                     Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity


     Read for                  User
       Sync
                St
                at
                 us
                     :1




                              Status
                               flag

                                                         30

                     Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity


     Read for                  User
       Sync
                St
                at
                 us
                     :1




                              Status
                               flag

                                                         30

                     Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity


     Read for                  User
       Sync




                                  Status: 1
                St
                at
                 us
                     :1




                              Status
                               flag

                                                         30

                     Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity


     Read for                                         Sync
                               User
       Sync                                          finished




                                  Status: 1
                St
                at
                 us
                     :1




                              Status
                               flag

                                                               30

                     Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity


     Read for                                         Sync
                               User
       Sync                                          finished




                                  Status: 1
                St
                at
                 us
                     :1




                              Status
                               flag

                                                               30

                     Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Problem: Data integrity


     Read for                                             Sync
                               User
       Sync                                              finished




                                                     0
                                  Status: 1
                St




                                                   s:
                at




                                                 u
                                              at
                 us




                                              St
                     :1




                              Status
                               flag

                                                                   30

                     Live on Stage - Dominik Jungowski
Problems & Solutions




                                          31

      Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Solution: Table locking




                                                    31

                Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Solution: Table locking
mysql> LOCK TABLES speaker WRITE;




                                                        31

                    Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Solution: Table locking
mysql> LOCK TABLES speaker WRITE;


‣ Problem: Whole table is locked for reading and
    writing




                                                        31

                    Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Solution: Table locking
mysql> LOCK TABLES speaker WRITE;


‣ Problem: Whole table is locked for reading and
    writing
mysql> SELECT * FROM speaker WHERE status = 1 FOR UPDATE;




                                                            31

                    Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Solution: Table locking
mysql> LOCK TABLES speaker WRITE;


‣ Problem: Whole table is locked for reading and
    writing
mysql> SELECT * FROM speaker WHERE status = 1 FOR UPDATE;


‣ Only locks the selected rows



                                                            31

                    Live on Stage - Dominik Jungowski
Problems & Solutions
‣ Solution: Table locking
mysql> LOCK TABLES speaker WRITE;


‣ Problem: Whole table is locked for reading and
    writing
mysql> SELECT * FROM speaker WHERE status = 1 FOR UPDATE;


‣ Only locks the selected rows
‣ Reading other data from table is still possible

                                                            31

                    Live on Stage - Dominik Jungowski
Contact me
‣ Weblog: www.phpdevblog.net


‣ Twitter: www.twitter.com/djungowski


‣ Xing: http://www.xing.com/profile/
    Dominik_Jungowski




                                                   32

               Live on Stage - Dominik Jungowski
Questions?


                                     33

 Live on Stage - Dominik Jungowski
Thank you!


                                     34

 Live on Stage - Dominik Jungowski

More Related Content

More from Dominik Jungowski

Stolpersteine agiler Methoden
Stolpersteine agiler MethodenStolpersteine agiler Methoden
Stolpersteine agiler Methoden
Dominik Jungowski
 
Distributed work with Gearman
Distributed work with GearmanDistributed work with Gearman
Distributed work with Gearman
Dominik Jungowski
 

More from Dominik Jungowski (20)

Agil vs. $kunde
Agil vs. $kundeAgil vs. $kunde
Agil vs. $kunde
 
Definition of almost done
Definition of almost doneDefinition of almost done
Definition of almost done
 
TestDrivenDevelopment.php
TestDrivenDevelopment.phpTestDrivenDevelopment.php
TestDrivenDevelopment.php
 
Definition of almost done
Definition of almost doneDefinition of almost done
Definition of almost done
 
Definition of almost Done
Definition of almost DoneDefinition of almost Done
Definition of almost Done
 
Scrum, Kanban oder vielleicht beides?
Scrum, Kanban oder vielleicht beides?Scrum, Kanban oder vielleicht beides?
Scrum, Kanban oder vielleicht beides?
 
Schlank oder krank? Mit Lean Startup zum Erfolg
Schlank oder krank? Mit Lean Startup zum ErfolgSchlank oder krank? Mit Lean Startup zum Erfolg
Schlank oder krank? Mit Lean Startup zum Erfolg
 
Agile Fortschritte erfolgreich verhindern
Agile Fortschritte erfolgreich verhindernAgile Fortschritte erfolgreich verhindern
Agile Fortschritte erfolgreich verhindern
 
Kanban in der Softwareentwicklung
Kanban in der SoftwareentwicklungKanban in der Softwareentwicklung
Kanban in der Softwareentwicklung
 
Agile fortschritte erfolgreich verhindern
Agile fortschritte erfolgreich verhindernAgile fortschritte erfolgreich verhindern
Agile fortschritte erfolgreich verhindern
 
Von Fischen und Menschen
Von Fischen und MenschenVon Fischen und Menschen
Von Fischen und Menschen
 
The five dysfunctions of a team
The five dysfunctions of a teamThe five dysfunctions of a team
The five dysfunctions of a team
 
Stolpersteine agiler Methoden
Stolpersteine agiler MethodenStolpersteine agiler Methoden
Stolpersteine agiler Methoden
 
Arbeitsmethoden
ArbeitsmethodenArbeitsmethoden
Arbeitsmethoden
 
Distributed work with Gearman
Distributed work with GearmanDistributed work with Gearman
Distributed work with Gearman
 
RIA - Entwicklung mit Ext JS
RIA - Entwicklung mit Ext JSRIA - Entwicklung mit Ext JS
RIA - Entwicklung mit Ext JS
 
RIA - Entwicklung mit Ext JS
RIA - Entwicklung mit Ext JSRIA - Entwicklung mit Ext JS
RIA - Entwicklung mit Ext JS
 
Ziele setzen und erreichen
Ziele setzen und erreichenZiele setzen und erreichen
Ziele setzen und erreichen
 
Pecha Kucha
Pecha KuchaPecha Kucha
Pecha Kucha
 
Better Quality through Scrum (2011)
Better Quality through Scrum (2011)Better Quality through Scrum (2011)
Better Quality through Scrum (2011)
 

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 

Recently uploaded (20)

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 

Live On Stage

  • 1. Live on Stage Dominik Jungowski - May 14, 2010 Live on Stage - Dominik Jungowski
  • 2. Agenda 2 Live on Stage - Dominik Jungowski
  • 3. Agenda ‣ What is Staging? 2 Live on Stage - Dominik Jungowski
  • 4. Agenda ‣ What is Staging? ‣ Reasons for Staging 2 Live on Stage - Dominik Jungowski
  • 5. Agenda ‣ What is Staging? ‣ Reasons for Staging ‣ Implementation 2 Live on Stage - Dominik Jungowski
  • 6. Agenda ‣ What is Staging? ‣ Reasons for Staging ‣ Implementation ‣ Adding a staging layer 2 Live on Stage - Dominik Jungowski
  • 7. Agenda ‣ What is Staging? ‣ Reasons for Staging ‣ Implementation ‣ Adding a staging layer ‣ Problems and Solutions 2 Live on Stage - Dominik Jungowski
  • 8. About me 3 Live on Stage - Dominik Jungowski
  • 9. About me ‣ 25 years old 3 Live on Stage - Dominik Jungowski
  • 10. About me ‣ 25 years old ‣ Employed at CHIP Xonio Online GmbH 3 Live on Stage - Dominik Jungowski
  • 11. About me ‣ 25 years old ‣ Employed at CHIP Xonio Online GmbH ➡ www.chip.de 3 Live on Stage - Dominik Jungowski
  • 12. About me ‣ 25 years old ‣ Employed at CHIP Xonio Online GmbH ➡ www.chip.de ➡ download.chip.eu 3 Live on Stage - Dominik Jungowski
  • 13. About me ‣ 25 years old ‣ Employed at CHIP Xonio Online GmbH ➡ www.chip.de ➡ download.chip.eu ‣ ScrumMaster and Developer at price comparison 3 Live on Stage - Dominik Jungowski
  • 14. About me ‣ 25 years old ‣ Employed at CHIP Xonio Online GmbH ➡ www.chip.de ➡ download.chip.eu ‣ ScrumMaster and Developer at price comparison ‣ Part - time studies in Psychology at distance university FernUni Hagen 3 Live on Stage - Dominik Jungowski
  • 15. What is staging? Live on Stage - Dominik Jungowski
  • 16. What is Staging? Usual Database Design: 5 Live on Stage - Dominik Jungowski
  • 17. What is Staging? Usual Database Design: Databa 5 Live on Stage - Dominik Jungowski
  • 18. What is Staging? Usual Database Design: Databa Website 5 Live on Stage - Dominik Jungowski
  • 19. What is Staging? Usual Database Design: Databa Website 5 Live on Stage - Dominik Jungowski
  • 20. What is Staging? Usual Database Design: Databa Website Admin 5 Live on Stage - Dominik Jungowski
  • 21. What is Staging? Usual Database Design: Databa Website Admin 5 Live on Stage - Dominik Jungowski
  • 22. What is Staging? Staging Database Design: 6 Live on Stage - Dominik Jungowski
  • 23. What is Staging? Staging Database Design: Databa 6 Live on Stage - Dominik Jungowski
  • 24. What is Staging? Staging Database Design: Databa Website 6 Live on Stage - Dominik Jungowski
  • 25. What is Staging? Staging Database Design: Databa Website 6 Live on Stage - Dominik Jungowski
  • 26. What is Staging? Staging Database Design: Databa Databa Website 6 Live on Stage - Dominik Jungowski
  • 27. What is Staging? Staging Database Design: Databa Databa Website Admin 6 Live on Stage - Dominik Jungowski
  • 28. What is Staging? Staging Database Design: Databa Databa Website Admin 6 Live on Stage - Dominik Jungowski
  • 29. What is Staging? Staging Database Design: Databa Databa Website Admin 6 Live on Stage - Dominik Jungowski
  • 30. What is Staging? Staging Database Design: Databa Sync Databa Website Admin 6 Live on Stage - Dominik Jungowski
  • 31. Reasons for staging Live on Stage - Dominik Jungowski
  • 32. Reasons for Staging 8 Live on Stage - Dominik Jungowski
  • 33. Reasons for Staging ‣ Security 8 Live on Stage - Dominik Jungowski
  • 34. Reasons for Staging ‣ Security ➡ no sensitive data on live system 8 Live on Stage - Dominik Jungowski
  • 35. Reasons for Staging ‣ Security ➡ no sensitive data on live system ➡ only the essential data is synced 8 Live on Stage - Dominik Jungowski
  • 36. Reasons for Staging ‣ Security ➡ no sensitive data on live system ➡ only the essential data is synced ‣ Quality 8 Live on Stage - Dominik Jungowski
  • 37. Reasons for Staging ‣ Security ➡ no sensitive data on live system ➡ only the essential data is synced ‣ Quality ➡ no changes directly on live system 8 Live on Stage - Dominik Jungowski
  • 38. Reasons for Staging ‣ Security ➡ no sensitive data on live system ➡ only the essential data is synced ‣ Quality ➡ no changes directly on live system ➡ more time to prevent corruption/errors on live system (user errors, broken imports, etc.) 8 Live on Stage - Dominik Jungowski
  • 39. Reasons for Staging ‣ Performance 9 Live on Stage - Dominik Jungowski
  • 40. Reasons for Staging ‣ Performance ➡ Normalized data on staging database 9 Live on Stage - Dominik Jungowski
  • 41. Reasons for Staging ‣ Performance ➡ Normalized data on staging database ➡ Performance optimized / flat data on live database 9 Live on Stage - Dominik Jungowski
  • 42. Reasons for Staging ‣ Performance ➡ Normalized data on staging database ➡ Performance optimized / flat data on live database ➡ no constraints on live system possible 9 Live on Stage - Dominik Jungowski
  • 43. Implementat ion Live on Stage - Dominik Jungowski
  • 44. Implementation 11 Live on Stage - Dominik Jungowski
  • 45. Implementation ‣ Data is synced 11 Live on Stage - Dominik Jungowski
  • 46. Implementation ‣ Data is synced ➡ some kind of status flag in staging db is needed 11 Live on Stage - Dominik Jungowski
  • 47. Implementation ‣ Data is synced ➡ some kind of status flag in staging db is needed ‣ Status needed for 11 Live on Stage - Dominik Jungowski
  • 48. Implementation ‣ Data is synced ➡ some kind of status flag in staging db is needed ‣ Status needed for ➡ Changed data 11 Live on Stage - Dominik Jungowski
  • 49. Implementation ‣ Data is synced ➡ some kind of status flag in staging db is needed ‣ Status needed for ➡ Changed data ➡ Unchanged data 11 Live on Stage - Dominik Jungowski
  • 50. Implementation ‣ Data is synced ➡ some kind of status flag in staging db is needed ‣ Status needed for ➡ Changed data ➡ Unchanged data ➡ Deleted data on staging, but not on live system 11 Live on Stage - Dominik Jungowski
  • 51. Implementation ‣ Data is synced ➡ some kind of status flag in staging db is needed ‣ Status needed for ➡ Changed data ➡ Unchanged data ➡ Deleted data on staging, but not on live system ‣ Maybe useful 11 Live on Stage - Dominik Jungowski
  • 52. Implementation ‣ Data is synced ➡ some kind of status flag in staging db is needed ‣ Status needed for ➡ Changed data ➡ Unchanged data ➡ Deleted data on staging, but not on live system ‣ Maybe useful ➡ Deleted on live system 11 Live on Stage - Dominik Jungowski
  • 53. Implementation The Status - Cycle 12 Live on Stage - Dominik Jungowski
  • 54. Implementation The Status - Cycle Import 12 Live on Stage - Dominik Jungowski
  • 55. Implementation The Status - Cycle Import 12 Live on Stage - Dominik Jungowski
  • 56. Implementation The Status - Cycle ne w or ch an ge dd ata Import 12 Live on Stage - Dominik Jungowski
  • 57. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Import 12 Live on Stage - Dominik Jungowski
  • 58. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Import 12 Live on Stage - Dominik Jungowski
  • 59. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Sync Import 12 Live on Stage - Dominik Jungowski
  • 60. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Sync Import No change [0] 12 Live on Stage - Dominik Jungowski
  • 61. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Sync Import No change [0] 12 Live on Stage - Dominik Jungowski
  • 62. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Sync Import rem ov ed da ta No change [0] 12 Live on Stage - Dominik Jungowski
  • 63. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Sync Import rem ov ed da ta No Changed change Deleted [0] [3] 12 Live on Stage - Dominik Jungowski
  • 64. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Sync Import rem ov ed da ta No Changed change Deleted [0] [3] 12 Live on Stage - Dominik Jungowski
  • 65. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Sync Import rem ov ed da ta No Changed change Deleted [0] [3] 12 Live on Stage - Dominik Jungowski
  • 66. Implementation The Status - Cycle Changed [1] ne w or ch an ge dd ata Sync Sync Import rem ov ed da ta No Changed change Deleted [0] [3] 12 Live on Stage - Dominik Jungowski
  • 67. Implementation The Status - Cycle Changed Deleted [1] [2] ne w or ch an ge dd ata Sync Sync Import rem ov ed da ta No Changed change Deleted [0] [3] 12 Live on Stage - Dominik Jungowski
  • 68. Implementation The Status - Cycle Changed Deleted [1] [2] ne w or ch an ge dd ata Sync Sync Import rem ov ed da ta No Changed change Deleted [0] [3] 12 Live on Stage - Dominik Jungowski
  • 69. Implementation Why 0, 1, 2, 3? Live on Stage - Dominik Jungowski
  • 70. Implementation Why 0, 1, 2, 3? Let‘s take a look at the binary numbers! Live on Stage - Dominik Jungowski
  • 71. Implementation 14 Live on Stage - Dominik Jungowski
  • 72. Implementation No change [0] 14 Live on Stage - Dominik Jungowski
  • 73. Implementation No change [0] = 14 Live on Stage - Dominik Jungowski
  • 74. Implementation No change [0] = 0000 14 Live on Stage - Dominik Jungowski
  • 75. Implementation No change [0] = 0000 Changed [1] 14 Live on Stage - Dominik Jungowski
  • 76. Implementation No change [0] = 0000 Changed [1] = 14 Live on Stage - Dominik Jungowski
  • 77. Implementation No change [0] = 0000 Changed [1] = 0001 14 Live on Stage - Dominik Jungowski
  • 78. Implementation No change [0] = 0000 Changed [1] = 0001 Deleted [2] 14 Live on Stage - Dominik Jungowski
  • 79. Implementation No change [0] = 0000 Changed [1] = 0001 Deleted [2] = 14 Live on Stage - Dominik Jungowski
  • 80. Implementation No change [0] = 0000 Changed [1] = 0001 Deleted [2] = 0010 14 Live on Stage - Dominik Jungowski
  • 81. Implementation No change [0] = 0000 Changed [1] = 0001 Deleted [2] = 0010 Changed Deleted [3] 14 Live on Stage - Dominik Jungowski
  • 82. Implementation No change [0] = 0000 Changed [1] = 0001 Deleted [2] = 0010 Changed Deleted [3] = 14 Live on Stage - Dominik Jungowski
  • 83. Implementation No change [0] = 0000 Changed [1] = 0001 Deleted [2] = 0010 Changed Deleted [3] = 0011 14 Live on Stage - Dominik Jungowski
  • 84. Implementation No change [0] = 0000 Changed [1] = 0001 Deleted [2] = 0010 Changed Deleted [3] = 0011 = 0001 | 0010 14 Live on Stage - Dominik Jungowski
  • 85. Implementation Using the binary flags in PHP class phpDay_Sync { /** * Status for changed data * Binary: 0001 */ const STATUS_CHANGED = 1; /** * Status for removed data * Binary: 0010 */ const STATUS_DELETED = 2; ... } 15 Live on Stage - Dominik Jungowski
  • 86. Implementation Using the binary flags in PHP 16 Live on Stage - Dominik Jungowski
  • 87. Implementation Using the binary flags in PHP // Speaker status has changed 16 Live on Stage - Dominik Jungowski
  • 88. Implementation Using the binary flags in PHP // Speaker status has changed $speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED; 16 Live on Stage - Dominik Jungowski
  • 89. Implementation Using the binary flags in PHP // Speaker status has changed $speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED; // Speaker has been synced to live system 16 Live on Stage - Dominik Jungowski
  • 90. Implementation Using the binary flags in PHP // Speaker status has changed $speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED; // Speaker has been synced to live system $speaker[‘status‘] = 16 Live on Stage - Dominik Jungowski
  • 91. Implementation Using the binary flags in PHP // Speaker status has changed $speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED; // Speaker has been synced to live system $speaker[‘status‘] = (phpDay_Sync::STATUS_CHANGED & phpDay_Sync::STATUS_DELETED); 16 Live on Stage - Dominik Jungowski
  • 92. Implementation Using the binary flags in PHP // Speaker status has changed $speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED; // Speaker has been synced to live system $speaker[‘status‘] = (phpDay_Sync::STATUS_CHANGED & phpDay_Sync::STATUS_DELETED); //... or easier :-) 16 Live on Stage - Dominik Jungowski
  • 93. Implementation Using the binary flags in PHP // Speaker status has changed $speaker[‘status‘] = phpDay_Sync::STATUS_CHANGED; // Speaker has been synced to live system $speaker[‘status‘] = (phpDay_Sync::STATUS_CHANGED & phpDay_Sync::STATUS_DELETED); //... or easier :-) $speaker[‘status‘] = 0; 16 Live on Stage - Dominik Jungowski
  • 94. Implementation Using the binary flags in PHP 17 Live on Stage - Dominik Jungowski
  • 95. Implementation Using the binary flags in PHP // Speaker didn‘t show up in import file 17 Live on Stage - Dominik Jungowski
  • 96. Implementation Using the binary flags in PHP // Speaker didn‘t show up in import file // 0001 | 0010 = 0011 17 Live on Stage - Dominik Jungowski
  • 97. Implementation Using the binary flags in PHP // Speaker didn‘t show up in import file // 0001 | 0010 = 0011 $speaker[‘status‘] = 17 Live on Stage - Dominik Jungowski
  • 98. Implementation Using the binary flags in PHP // Speaker didn‘t show up in import file // 0001 | 0010 = 0011 $speaker[‘status‘] = (phpDay_Sync::STATUS_CHANGED | phpDay_Sync::STATUS_DELETED); 17 Live on Stage - Dominik Jungowski
  • 99. Implementation Using the binary flags in PHP // Speaker didn‘t show up in import file // 0001 | 0010 = 0011 $speaker[‘status‘] = (phpDay_Sync::STATUS_CHANGED | phpDay_Sync::STATUS_DELETED); // Speaker has been deleted on live system 17 Live on Stage - Dominik Jungowski
  • 100. Implementation Using the binary flags in PHP // Speaker didn‘t show up in import file // 0001 | 0010 = 0011 $speaker[‘status‘] = (phpDay_Sync::STATUS_CHANGED | phpDay_Sync::STATUS_DELETED); // Speaker has been deleted on live system $speaker[‘status‘] = phpDay_Sync::STATUS_DELETED; 17 Live on Stage - Dominik Jungowski
  • 101. Binary AND & 0 1 2 3 0 0 0 0 1 0 0 1 2 0 0 2 3 0 1 2 18 Live on Stage - Dominik Jungowski
  • 102. Binary AND & 0 1 2 3 0000 0000 0000 0 & 0001 & 0010 & 0011 = 0000 = 0000 = 0000 0001 0001 0001 1 & 0000 & 0010 & 0011 = 0000 = 0000 = 0001 0010 0010 0010 2 & 0000 & 0001 & 0011 = 0000 = 0000 = 0010 0011 0011 0010 3 & 0000 & 0001 & 0011 = 0000 = 0001 = 0010 19 Live on Stage - Dominik Jungowski
  • 103. Binary OR | 0 1 2 3 0 1 2 3 1 1 3 3 2 2 3 3 3 3 3 3 20 Live on Stage - Dominik Jungowski
  • 104. Binary OR | 0 1 2 3 0000 0000 0000 0 | 0001 | 0010 | 0011 = 0001 = 0010 = 0011 0001 0001 0001 1 | 0000 | 0010 | 0011 = 0001 = 0011 = 0011 0010 0001 0010 2 | 0000 | 0010 | 0011 = 0010 = 0011 = 0011 0011 0011 0011 3 | 0000 | 0001 | 0010 = 0010 = 0011 = 0011 21 Live on Stage - Dominik Jungowski
  • 105. Deleting on live system Status 3 Status 2 Live on Stage - Dominik Jungowski
  • 106. Implementation & 0 1 2 3 0 0 0 0 1 0 0 1 2 0 0 2 3 0 1 2 23 Live on Stage - Dominik Jungowski
  • 107. Implementation ... in PHP 24 Live on Stage - Dominik Jungowski
  • 108. Implementation ... in PHP // We‘ve synced the deleted speaker, status 3 => status 2 24 Live on Stage - Dominik Jungowski
  • 109. Implementation ... in PHP // We‘ve synced the deleted speaker, status 3 => status 2 // 0011 & 0010 = 0010 24 Live on Stage - Dominik Jungowski
  • 110. Implementation ... in PHP // We‘ve synced the deleted speaker, status 3 => status 2 // 0011 & 0010 = 0010 $speaker[‘status‘] = 24 Live on Stage - Dominik Jungowski
  • 111. Implementation ... in PHP // We‘ve synced the deleted speaker, status 3 => status 2 // 0011 & 0010 = 0010 $speaker[‘status‘] = ($speaker[‘status‘] & phpDay_Sync::STATUS_DELETED); 24 Live on Stage - Dominik Jungowski
  • 112. Implementation ... in PHP // We‘ve synced the deleted speaker, status 3 => status 2 // 0011 & 0010 = 0010 $speaker[‘status‘] = ($speaker[‘status‘] & phpDay_Sync::STATUS_DELETED); // or if you know you will never use more than those 4 status flags: 24 Live on Stage - Dominik Jungowski
  • 113. Implementation ... in PHP // We‘ve synced the deleted speaker, status 3 => status 2 // 0011 & 0010 = 0010 $speaker[‘status‘] = ($speaker[‘status‘] & phpDay_Sync::STATUS_DELETED); // or if you know you will never use more than those 4 status flags: $speaker[‘status‘] = phpDay_Sync::STATUS_CHANGEDELETED; 24 Live on Stage - Dominik Jungowski
  • 114. Implementation ... in MySQL 25 Live on Stage - Dominik Jungowski
  • 115. Implementation ... in MySQL // We‘ve synced the deleted speaker, status 3 => status 2 // 0011 & 0010 = 0010 $sql = ‘UPDATE speaker SET status = status & ‘ . phpDay_Sync::STATUS_DELETED; 25 Live on Stage - Dominik Jungowski
  • 116. Implementation ... in MySQL // We‘ve synced the deleted speaker, status 3 => status 2 // 0011 & 0010 = 0010 $sql = ‘UPDATE speaker SET status = status & ‘ . phpDay_Sync::STATUS_DELETED; ‣ But: Rather slow in MySQL 25 Live on Stage - Dominik Jungowski
  • 117. Implementation ... in MySQL // We‘ve synced the deleted speaker, status 3 => status 2 // 0011 & 0010 = 0010 $sql = ‘UPDATE speaker SET status = status & ‘ . phpDay_Sync::STATUS_DELETED; ‣ But: Rather slow in MySQL // We‘ve synced the deleted speaker, status 3 => status 2 // 0011 & 0010 = 0010 $status = $speaker->getStatus(); $sql = ‘UPDATE speaker SET status = ‘ . ($status & phpDay_Sync::STATUS_DELETED); 25 Live on Stage - Dominik Jungowski
  • 118. Adding a staging layer Things to consider Live on Stage - Dominik Jungowski
  • 119. Adding a staging layer 27 Live on Stage - Dominik Jungowski
  • 120. Adding a staging layer ‣ Distribution of cronjobs: 1 server ➝ 2 servers 27 Live on Stage - Dominik Jungowski
  • 121. Adding a staging layer ‣ Distribution of cronjobs: 1 server ➝ 2 servers ➡ Data you need on live system 27 Live on Stage - Dominik Jungowski
  • 122. Adding a staging layer ‣ Distribution of cronjobs: 1 server ➝ 2 servers ➡ Data you need on live system ➡ Data you need on staging system 27 Live on Stage - Dominik Jungowski
  • 123. Adding a staging layer ‣ Distribution of cronjobs: 1 server ➝ 2 servers ➡ Data you need on live system ➡ Data you need on staging system ➡ Data you need on both systems 27 Live on Stage - Dominik Jungowski
  • 124. Adding a staging layer ‣ Distribution of cronjobs: 1 server ➝ 2 servers ➡ Data you need on live system ➡ Data you need on staging system ➡ Data you need on both systems ‣ Write down all the cronjobs 27 Live on Stage - Dominik Jungowski
  • 125. Adding a staging layer ‣ Distribution of cronjobs: 1 server ➝ 2 servers ➡ Data you need on live system ➡ Data you need on staging system ➡ Data you need on both systems ‣ Write down all the cronjobs ‣ Decide where you need them 27 Live on Stage - Dominik Jungowski
  • 126. Adding a staging layer ‣ Switching live system 28 Live on Stage - Dominik Jungowski
  • 127. Adding a staging layer ‣ Switching live system Database server 28 Live on Stage - Dominik Jungowski
  • 128. Adding a staging layer ‣ Switching live system Old database Database server 28 Live on Stage - Dominik Jungowski
  • 129. Adding a staging layer ‣ Switching live system Old database Database server New (synced) database 28 Live on Stage - Dominik Jungowski
  • 130. Adding a staging layer ‣ Switching live system Old database Database Website server New (synced) database 28 Live on Stage - Dominik Jungowski
  • 131. Adding a staging layer ‣ Switching live system Old database Database Website server New (synced) database 28 Live on Stage - Dominik Jungowski
  • 132. Adding a staging layer ‣ Switching live system Old database Database Website server New (synced) database 28 Live on Stage - Dominik Jungowski
  • 133. Adding a staging layer ‣ Switching live system Old database Database Website server New (synced) database 28 Live on Stage - Dominik Jungowski
  • 134. Problems & Solutions 29 Live on Stage - Dominik Jungowski
  • 135. Problems & Solutions ‣ Problem: Data integrity 30 Live on Stage - Dominik Jungowski
  • 136. Problems & Solutions ‣ Problem: Data integrity Status flag 30 Live on Stage - Dominik Jungowski
  • 137. Problems & Solutions ‣ Problem: Data integrity Read for Sync Status flag 30 Live on Stage - Dominik Jungowski
  • 138. Problems & Solutions ‣ Problem: Data integrity Read for Sync Status flag 30 Live on Stage - Dominik Jungowski
  • 139. Problems & Solutions ‣ Problem: Data integrity Read for Sync St at us :1 Status flag 30 Live on Stage - Dominik Jungowski
  • 140. Problems & Solutions ‣ Problem: Data integrity Read for User Sync St at us :1 Status flag 30 Live on Stage - Dominik Jungowski
  • 141. Problems & Solutions ‣ Problem: Data integrity Read for User Sync St at us :1 Status flag 30 Live on Stage - Dominik Jungowski
  • 142. Problems & Solutions ‣ Problem: Data integrity Read for User Sync Status: 1 St at us :1 Status flag 30 Live on Stage - Dominik Jungowski
  • 143. Problems & Solutions ‣ Problem: Data integrity Read for Sync User Sync finished Status: 1 St at us :1 Status flag 30 Live on Stage - Dominik Jungowski
  • 144. Problems & Solutions ‣ Problem: Data integrity Read for Sync User Sync finished Status: 1 St at us :1 Status flag 30 Live on Stage - Dominik Jungowski
  • 145. Problems & Solutions ‣ Problem: Data integrity Read for Sync User Sync finished 0 Status: 1 St s: at u at us St :1 Status flag 30 Live on Stage - Dominik Jungowski
  • 146. Problems & Solutions 31 Live on Stage - Dominik Jungowski
  • 147. Problems & Solutions ‣ Solution: Table locking 31 Live on Stage - Dominik Jungowski
  • 148. Problems & Solutions ‣ Solution: Table locking mysql> LOCK TABLES speaker WRITE; 31 Live on Stage - Dominik Jungowski
  • 149. Problems & Solutions ‣ Solution: Table locking mysql> LOCK TABLES speaker WRITE; ‣ Problem: Whole table is locked for reading and writing 31 Live on Stage - Dominik Jungowski
  • 150. Problems & Solutions ‣ Solution: Table locking mysql> LOCK TABLES speaker WRITE; ‣ Problem: Whole table is locked for reading and writing mysql> SELECT * FROM speaker WHERE status = 1 FOR UPDATE; 31 Live on Stage - Dominik Jungowski
  • 151. Problems & Solutions ‣ Solution: Table locking mysql> LOCK TABLES speaker WRITE; ‣ Problem: Whole table is locked for reading and writing mysql> SELECT * FROM speaker WHERE status = 1 FOR UPDATE; ‣ Only locks the selected rows 31 Live on Stage - Dominik Jungowski
  • 152. Problems & Solutions ‣ Solution: Table locking mysql> LOCK TABLES speaker WRITE; ‣ Problem: Whole table is locked for reading and writing mysql> SELECT * FROM speaker WHERE status = 1 FOR UPDATE; ‣ Only locks the selected rows ‣ Reading other data from table is still possible 31 Live on Stage - Dominik Jungowski
  • 153. Contact me ‣ Weblog: www.phpdevblog.net ‣ Twitter: www.twitter.com/djungowski ‣ Xing: http://www.xing.com/profile/ Dominik_Jungowski 32 Live on Stage - Dominik Jungowski
  • 154. Questions? 33 Live on Stage - Dominik Jungowski
  • 155. Thank you! 34 Live on Stage - Dominik Jungowski

Editor's Notes