SlideShare a Scribd company logo
1 of 42
Download to read offline
The case file of
Mobage Open Platform	
  Mobage
                    	
 Toru Yamaguchi <zigorou@cpan.org>
   http://d.hatena.ne.jp/ZIGOROu/
             DeNA co.,ltd.
              2011/10/14
            YAPC Asia 2011
! 
     ! 
     ! 

! 


     ! 
!   Wikipedia
     ! 



! 
     ! 

     !          (Cause Analysis)
     !          (Failure Prevention)
     !          (Knowledge Distribution)
(   )
1 DeadLock                                     	

!         API (T                 )                           Dead Lock

     !                   API
                                     Internal Server Error

     ! 


! 
     !   Internal Server Error
(1)	
!                   API   GET

     !    totalResults             OpenSearch

!             totalResults
     SQL_CALC_FOUND_ROWS
     !                           SELECT

! 
     totalResults
     !   INSERT, DELETE         TRIGGER
(2)	
!                    SHOW INNODB STATUS
     !   Dead Lock
     ! 


! 
     !                UPDATE

          !                                 UPDATE

     ! 
BEGIN;

SELECT id FROM somedata_group WHERE name = ?;

INSERT INTO somedata(id, group_id, data, published_on)
VALUES(?, ?, ?, ?);

UPDATE somedata_summary SET total_results = total_results
+ 1, updated_on = ? WHERE group_id = ?;

COMMIT;
(3)	
!   Group
     ! 
     ! 


! 
     ! 
                                    UPDATE
               increment
     !                                  MySQL
          Dead Lock
(4)	

        Transaction	
   group_id = 1	
           Transaction	




                        group_id = 2	


                        group_id = 3	
           Transaction	
group_id = 3
UPDATE
                        group_id = 4	


                        group_id = 5	
           Transaction
(1)	
! 
     !            UPDATE                          w
     !                       SELECT               totalResults

     !   INSERT                 incr/decr        QUEUE
                         UPDATE
     !                totalResults

     !                      xaicron
(2)	
/* API                */

BEGIN;

INSERT INTO somedata(id, group_id, data, published_on)
VALUES(?, ?, ?, ?);

INSERT INTO somedata_summary_queue(id, group_id,
affected_number, published_on);

COMMIT;
(3)	
/* Batch Worker       */

BEGIN;

SELECT id, group_id, affected_number FROM
somegroup_summary_queue ORDER BY published_on ASC LIMIT 100;

/* group                               UPDATE */

UPDATE somedata_summary SET total_results = ?, updated_on = ?
WHERE group_id = ?;

…

DELETE somegroup_summary_queue WHERE id IN (?, ?, …, ?);

COMMIT;
(1)	
! 
     ! 

     ! 

     !         InnoDB    QUEUE
                 (      ) UPDATE


          ! 
(2)	
! 
     !    InnoDB            QUEUE              INDEX

          !   INSERT, DELETE         enqueue

     !                      queue
          WHERE        id
          ! 
               FOR UPDATE
     ! 
2 INSERT vs DELETE	

! 
     ! 

!          API (             T            )
     !          1            INSERT
     !        API
          purge
     !                            purge       (   )
                    INSERT

! 
     !       shard
(   )
(1)	
!              purge
     !           MASTER      DELETE                 SLAVE            ww
          !   DELETE
          !                          redo             SLAVE

     !                       sleep          wait                 DB
                                                      wait

          !                          wait

!                      wait
     !   SLAVE          Seconds_Behind_Master                 wait
     !                               wait
Loop::Sustainable (1)	
! 
! https://github.com/zigorou/p5-loop-sustainable
! 
     ! 
     ! 
     ! 
                   wait
          ! 
          !               Seconds_Behind_Master

     !                      b ry
Loop::Sustainable (2)	
         process	
                 process	
                                               2sec	
         process	
                                   process	

         process	
                             2sec	

                                   process	
         process	
                                               2sec	

         process	
                 process	

                                               2sec	

Seconds_Behind_Master : 10 sec	
   process	

                                               2sec
(2)	
!                               w

!   SET SESSION sql_log_bin = 0

     !   MASTER      SLAVE             DELETE


!             DELETE

     !                                          prefork
                       DELETE
                  xaicron                   (        )
(3)	
! 

!   DELETE

!   DELETE                    purge
     !    partitioning    API

!   STOP SLAVE       DB
    Master

     ! 
     ! 
(1)	
!                   DELETE
     !                                DELETE
     !   DELETE              SELECT

!                 MySQL
     ! 
          ! 
          !    RDBMS
     ! 

!   SET SESSION sql_log_bin=0
     !                           DELETE
(2)	
!              DELETE                       INSERT

     !               Partitioning

     !           Sharding


! 
     !    mysqldump –w      WHERE
(1)	
! 
     ! 

     ! 
     !   PRIMARY KEY

     ! 
     !                 ALTER TABLE some_table ADD
          KEY
     ! 
     !     M
(2)	
! 
     ! 
     !              DML

          !    incr/decr
     ! 

          ! 
3                    	
! 
! 
! 

     API    Push   friend timeline

     !                               DB


!                             API
(1)	
! 
     ! 
     ! 
     ! 

!                                       count,
     startIndex (LIMIT/OFFSET      )

! 
SELECT friend_user_id FROM friends WHERE user_id = ?;
/*                       */
SELECT user_id FROM user_app WHERE app_id = ? AND
user_id IN (?, ?, …, ?);

/*                        */
SELECT SQL_CALC_FOUND_ROWS user_id, nickname
FROM users WHERE user_id IN(?, ?, …, ?) LIMIT 50
OFFSET 0;

SELECT FOUND_ROWS();
LIMIT 50
                                 valid users    OFFSET 0	
                                  500 users	
               installed users
                 750 users	
  friend
1000 users
(2)	
!   friends       n:m, user_app     1:n, users        1:1
!   friends                                                 (    1000
              )         user_app



!   users               SQL_CALC_FOUND_ROWS
                           LIMIT, OFFSET

!                         friends

     !            Temporary Table                     INSERT    users
          JOIN
(1)	
! 
     ! selectall_arrayref
     ! 

!   SQL_CALC_FOUND_ROWS
     !   LIMIT, OFFSET                         COUNT(*)

     ! 

!   Temporary Table
     ! 
     ! 
     !       user_id         user_id
             LIMIT, OFFSET
(2)	
!   prepare, fetchall_arrayref($max_rows)
     !   DBI::st   fetchall_arrayref($max_rows)       $max_rows

     ! 
     !                 friends           1000

!               1000             users                 user_app

     !   1000

!                                             1000
     users
     !             1000

! 
installed users                          valid users
  friend                         installed users         750 users	
                 750 users	
1000 users	
                       1000 users	

               installed users                          valid users
                 750 users	
                             750 users	
  friend                         installed users
1000 users	
                       1000 users	
         100 users	
               installed users
                 750 users	
     installed users
                                   250 users	
  friend
1000 users	



    end
 iteration
(3)	
! 


! 

!   Iterator::GroupedRange
     !   http://search.cpan.org/dist/Iterator-GroupedRange/

!                              List::MoreUtils   natatime
              I::GR       (fetchall_arrayref($max_rows)
          )
(4)	
! 

!   friends             DB                      1000
    memcached        get/set

!    user_app           mapping                memcached
         ( install                                  )

!                      iteration    DB
          DB                       iteration    set

!                                       3

     !                                                 xaicron
(1)	
! 

     ! 


! 
     ! 
          w

!             kazuho
! 
     ! 
     ! 
     ! 

! 
     ! 
          xaicron
     ! 


! 

     ! 

More Related Content

Similar to Mobage Open Platform case file

"Mobage DBA Fight against Big Data" - NHN TE
"Mobage DBA Fight against Big Data" - NHN TE"Mobage DBA Fight against Big Data" - NHN TE
"Mobage DBA Fight against Big Data" - NHN TERyosuke IWANAGA
 
20th.陈晓鸣 百度海量日志分析架构及处理经验分享
20th.陈晓鸣 百度海量日志分析架构及处理经验分享20th.陈晓鸣 百度海量日志分析架构及处理经验分享
20th.陈晓鸣 百度海量日志分析架构及处理经验分享elevenma
 
Big Data @ Orange - Dev Day 2013 - part 2
Big Data @ Orange - Dev Day 2013 - part 2Big Data @ Orange - Dev Day 2013 - part 2
Big Data @ Orange - Dev Day 2013 - part 2ovarene
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performanceDuoyi Wu
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engineDuoyi Wu
 
Introduction aux Macros
Introduction aux MacrosIntroduction aux Macros
Introduction aux Macrosunivalence
 
Origins of Elixir programming language
Origins of Elixir programming languageOrigins of Elixir programming language
Origins of Elixir programming languagePivorak MeetUp
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา CC Omputer R Oom
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา CC Omputer R Oom
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา CC Omputer R Oom
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา CC Omputer R Oom
 
Introduction to Linux Exploit Development
Introduction to Linux Exploit DevelopmentIntroduction to Linux Exploit Development
Introduction to Linux Exploit Developmentjohndegruyter
 
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduceMongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduceTakahiro Inoue
 
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...Chris Fregly
 
Introduction to Spark
Introduction to SparkIntroduction to Spark
Introduction to SparkLi Ming Tsai
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
 
เฉลยคำตอบ O
เฉลยคำตอบ Oเฉลยคำตอบ O
เฉลยคำตอบ OSurapong Jakang
 
参考書選びと迷った時の勉強法。 #antama_ws
参考書選びと迷った時の勉強法。 #antama_ws参考書選びと迷った時の勉強法。 #antama_ws
参考書選びと迷った時の勉強法。 #antama_wsTakahiro Yoshimura
 

Similar to Mobage Open Platform case file (20)

"Mobage DBA Fight against Big Data" - NHN TE
"Mobage DBA Fight against Big Data" - NHN TE"Mobage DBA Fight against Big Data" - NHN TE
"Mobage DBA Fight against Big Data" - NHN TE
 
20th.陈晓鸣 百度海量日志分析架构及处理经验分享
20th.陈晓鸣 百度海量日志分析架构及处理经验分享20th.陈晓鸣 百度海量日志分析架构及处理经验分享
20th.陈晓鸣 百度海量日志分析架构及处理经验分享
 
Big Data @ Orange - Dev Day 2013 - part 2
Big Data @ Orange - Dev Day 2013 - part 2Big Data @ Orange - Dev Day 2013 - part 2
Big Data @ Orange - Dev Day 2013 - part 2
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
 
Virtual machine and javascript engine
Virtual machine and javascript engineVirtual machine and javascript engine
Virtual machine and javascript engine
 
Introduction aux Macros
Introduction aux MacrosIntroduction aux Macros
Introduction aux Macros
 
Hadoop I/O Analysis
Hadoop I/O AnalysisHadoop I/O Analysis
Hadoop I/O Analysis
 
Origins of Elixir programming language
Origins of Elixir programming languageOrigins of Elixir programming language
Origins of Elixir programming language
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
 
การเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา Cการเขียนโปรแกรมด้วยภาษา C
การเขียนโปรแกรมด้วยภาษา C
 
Introduction to Linux Exploit Development
Introduction to Linux Exploit DevelopmentIntroduction to Linux Exploit Development
Introduction to Linux Exploit Development
 
MongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduceMongoDB: Replication,Sharding,MapReduce
MongoDB: Replication,Sharding,MapReduce
 
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
 
Introduction to Spark
Introduction to SparkIntroduction to Spark
Introduction to Spark
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
เฉลยคำตอบ O
เฉลยคำตอบ Oเฉลยคำตอบ O
เฉลยคำตอบ O
 
参考書選びと迷った時の勉強法。 #antama_ws
参考書選びと迷った時の勉強法。 #antama_ws参考書選びと迷った時の勉強法。 #antama_ws
参考書選びと迷った時の勉強法。 #antama_ws
 

More from Toru Yamaguchi

これからの Microservices
これからの Microservicesこれからの Microservices
これからの MicroservicesToru Yamaguchi
 
OAuth 2.0 Web Messaging Response Mode - OpenID Summit Tokyo 2015
OAuth 2.0 Web Messaging Response Mode - OpenID Summit Tokyo 2015OAuth 2.0 Web Messaging Response Mode - OpenID Summit Tokyo 2015
OAuth 2.0 Web Messaging Response Mode - OpenID Summit Tokyo 2015Toru Yamaguchi
 
Mobage Connect と Identity 関連技術への取り組み - OpenID Summit Tokyo 2015
Mobage Connect と Identity 関連技術への取り組み - OpenID Summit Tokyo 2015Mobage Connect と Identity 関連技術への取り組み - OpenID Summit Tokyo 2015
Mobage Connect と Identity 関連技術への取り組み - OpenID Summit Tokyo 2015Toru Yamaguchi
 
革新的ブラウザゲームを支えるプラットフォーム技術
革新的ブラウザゲームを支えるプラットフォーム技術革新的ブラウザゲームを支えるプラットフォーム技術
革新的ブラウザゲームを支えるプラットフォーム技術Toru Yamaguchi
 
技術選択とアーキテクトの役割 (要約版)
技術選択とアーキテクトの役割 (要約版)技術選択とアーキテクトの役割 (要約版)
技術選択とアーキテクトの役割 (要約版)Toru Yamaguchi
 
技術選択とアーキテクトの役割
技術選択とアーキテクトの役割技術選択とアーキテクトの役割
技術選択とアーキテクトの役割Toru Yamaguchi
 
How to bake delicious cookie (RESTful Meetup #03)
How to bake delicious cookie (RESTful Meetup #03)How to bake delicious cookie (RESTful Meetup #03)
How to bake delicious cookie (RESTful Meetup #03)Toru Yamaguchi
 
JSON Based Web Services
JSON Based Web ServicesJSON Based Web Services
JSON Based Web ServicesToru Yamaguchi
 
ngCore engine for mobage platform
ngCore engine for mobage platformngCore engine for mobage platform
ngCore engine for mobage platformToru Yamaguchi
 
Inside mobage platform
Inside mobage platformInside mobage platform
Inside mobage platformToru Yamaguchi
 
mbga Open Platform and Perl
mbga Open Platform and Perlmbga Open Platform and Perl
mbga Open Platform and PerlToru Yamaguchi
 
Inside mbga Open Platform API architecture
Inside mbga Open Platform API architectureInside mbga Open Platform API architecture
Inside mbga Open Platform API architectureToru Yamaguchi
 
Introduction OpenID Authentication 2.0 Revival
Introduction OpenID Authentication 2.0 RevivalIntroduction OpenID Authentication 2.0 Revival
Introduction OpenID Authentication 2.0 RevivalToru Yamaguchi
 
Introduction OpenID Authentication 2.0
Introduction OpenID Authentication 2.0Introduction OpenID Authentication 2.0
Introduction OpenID Authentication 2.0Toru Yamaguchi
 
The Security of OpenID Authentication 2.0
The Security of OpenID Authentication 2.0The Security of OpenID Authentication 2.0
The Security of OpenID Authentication 2.0Toru Yamaguchi
 
Customization of DBIC::Schema::Loader
Customization of DBIC::Schema::LoaderCustomization of DBIC::Schema::Loader
Customization of DBIC::Schema::LoaderToru Yamaguchi
 

More from Toru Yamaguchi (20)

これからの Microservices
これからの Microservicesこれからの Microservices
これからの Microservices
 
OAuth 2.0 Web Messaging Response Mode - OpenID Summit Tokyo 2015
OAuth 2.0 Web Messaging Response Mode - OpenID Summit Tokyo 2015OAuth 2.0 Web Messaging Response Mode - OpenID Summit Tokyo 2015
OAuth 2.0 Web Messaging Response Mode - OpenID Summit Tokyo 2015
 
Mobage Connect と Identity 関連技術への取り組み - OpenID Summit Tokyo 2015
Mobage Connect と Identity 関連技術への取り組み - OpenID Summit Tokyo 2015Mobage Connect と Identity 関連技術への取り組み - OpenID Summit Tokyo 2015
Mobage Connect と Identity 関連技術への取り組み - OpenID Summit Tokyo 2015
 
革新的ブラウザゲームを支えるプラットフォーム技術
革新的ブラウザゲームを支えるプラットフォーム技術革新的ブラウザゲームを支えるプラットフォーム技術
革新的ブラウザゲームを支えるプラットフォーム技術
 
技術選択とアーキテクトの役割 (要約版)
技術選択とアーキテクトの役割 (要約版)技術選択とアーキテクトの役割 (要約版)
技術選択とアーキテクトの役割 (要約版)
 
技術選択とアーキテクトの役割
技術選択とアーキテクトの役割技術選択とアーキテクトの役割
技術選択とアーキテクトの役割
 
How to bake delicious cookie (RESTful Meetup #03)
How to bake delicious cookie (RESTful Meetup #03)How to bake delicious cookie (RESTful Meetup #03)
How to bake delicious cookie (RESTful Meetup #03)
 
JSON Based Web Services
JSON Based Web ServicesJSON Based Web Services
JSON Based Web Services
 
ngCore engine for mobage platform
ngCore engine for mobage platformngCore engine for mobage platform
ngCore engine for mobage platform
 
Inside mobage platform
Inside mobage platformInside mobage platform
Inside mobage platform
 
mbga Open Platform and Perl
mbga Open Platform and Perlmbga Open Platform and Perl
mbga Open Platform and Perl
 
Inside mbga Open Platform API architecture
Inside mbga Open Platform API architectureInside mbga Open Platform API architecture
Inside mbga Open Platform API architecture
 
Introduction OpenID Authentication 2.0 Revival
Introduction OpenID Authentication 2.0 RevivalIntroduction OpenID Authentication 2.0 Revival
Introduction OpenID Authentication 2.0 Revival
 
OpenID Mobile Profile
OpenID Mobile ProfileOpenID Mobile Profile
OpenID Mobile Profile
 
Introduction OpenID Authentication 2.0
Introduction OpenID Authentication 2.0Introduction OpenID Authentication 2.0
Introduction OpenID Authentication 2.0
 
OpenID 2009
OpenID 2009OpenID 2009
OpenID 2009
 
Mobile Openid
Mobile OpenidMobile Openid
Mobile Openid
 
Client Side Cache
Client Side CacheClient Side Cache
Client Side Cache
 
The Security of OpenID Authentication 2.0
The Security of OpenID Authentication 2.0The Security of OpenID Authentication 2.0
The Security of OpenID Authentication 2.0
 
Customization of DBIC::Schema::Loader
Customization of DBIC::Schema::LoaderCustomization of DBIC::Schema::Loader
Customization of DBIC::Schema::Loader
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 

Mobage Open Platform case file

  • 1. The case file of Mobage Open Platform Mobage Toru Yamaguchi <zigorou@cpan.org> http://d.hatena.ne.jp/ZIGOROu/ DeNA co.,ltd. 2011/10/14 YAPC Asia 2011
  • 2. !  !  !  !  ! 
  • 3. !   Wikipedia !  !  !  !  (Cause Analysis) !  (Failure Prevention) !  (Knowledge Distribution)
  • 4. ( )
  • 5. 1 DeadLock !  API (T ) Dead Lock !  API Internal Server Error !  !  !   Internal Server Error
  • 6. (1) !  API GET ! totalResults OpenSearch !  totalResults SQL_CALC_FOUND_ROWS !  SELECT !  totalResults !   INSERT, DELETE TRIGGER
  • 7. (2) !  SHOW INNODB STATUS !   Dead Lock !  !  !  UPDATE !  UPDATE ! 
  • 8. BEGIN; SELECT id FROM somedata_group WHERE name = ?; INSERT INTO somedata(id, group_id, data, published_on) VALUES(?, ?, ?, ?); UPDATE somedata_summary SET total_results = total_results + 1, updated_on = ? WHERE group_id = ?; COMMIT;
  • 9. (3) !   Group !  !  !  !  UPDATE increment !  MySQL Dead Lock
  • 10. (4) Transaction group_id = 1 Transaction group_id = 2 group_id = 3 Transaction group_id = 3 UPDATE group_id = 4 group_id = 5 Transaction
  • 11. (1) !  !  UPDATE w !  SELECT totalResults !   INSERT incr/decr QUEUE UPDATE !  totalResults !  xaicron
  • 12. (2) /* API */ BEGIN; INSERT INTO somedata(id, group_id, data, published_on) VALUES(?, ?, ?, ?); INSERT INTO somedata_summary_queue(id, group_id, affected_number, published_on); COMMIT;
  • 13. (3) /* Batch Worker */ BEGIN; SELECT id, group_id, affected_number FROM somegroup_summary_queue ORDER BY published_on ASC LIMIT 100; /* group UPDATE */ UPDATE somedata_summary SET total_results = ?, updated_on = ? WHERE group_id = ?; … DELETE somegroup_summary_queue WHERE id IN (?, ?, …, ?); COMMIT;
  • 14. (1) !  !  !  !  InnoDB QUEUE ( ) UPDATE ! 
  • 15. (2) !  ! InnoDB QUEUE INDEX !   INSERT, DELETE enqueue !  queue WHERE id !  FOR UPDATE ! 
  • 16.
  • 17. 2 INSERT vs DELETE !  !  !  API ( T ) !  1 INSERT !  API purge !  purge ( ) INSERT !  !  shard
  • 18. ( )
  • 19.
  • 20. (1) !  purge !  MASTER DELETE SLAVE ww !   DELETE !  redo SLAVE !  sleep wait DB wait !  wait !  wait !   SLAVE Seconds_Behind_Master wait !  wait
  • 21. Loop::Sustainable (1) !  ! https://github.com/zigorou/p5-loop-sustainable !  !  !  !  wait !  !  Seconds_Behind_Master !  b ry
  • 22. Loop::Sustainable (2) process process 2sec process process process 2sec process process 2sec process process 2sec Seconds_Behind_Master : 10 sec process 2sec
  • 23. (2) !  w !   SET SESSION sql_log_bin = 0 !   MASTER SLAVE DELETE !  DELETE !  prefork DELETE xaicron ( )
  • 24. (3) !  !   DELETE !   DELETE purge !  partitioning API !   STOP SLAVE DB Master !  ! 
  • 25. (1) !  DELETE !  DELETE !   DELETE SELECT !  MySQL !  !  !  RDBMS !  !   SET SESSION sql_log_bin=0 !  DELETE
  • 26. (2) !  DELETE INSERT !  Partitioning !  Sharding !  ! mysqldump –w WHERE
  • 27. (1) !  !  !  !   PRIMARY KEY !  !  ALTER TABLE some_table ADD KEY !  !  M
  • 28. (2) !  !  !  DML !  incr/decr !  ! 
  • 29.
  • 30. 3 !  !  !  API Push friend timeline !  DB !  API
  • 31. (1) !  !  !  !  !  count, startIndex (LIMIT/OFFSET ) ! 
  • 32. SELECT friend_user_id FROM friends WHERE user_id = ?; /* */ SELECT user_id FROM user_app WHERE app_id = ? AND user_id IN (?, ?, …, ?); /* */ SELECT SQL_CALC_FOUND_ROWS user_id, nickname FROM users WHERE user_id IN(?, ?, …, ?) LIMIT 50 OFFSET 0; SELECT FOUND_ROWS();
  • 33. LIMIT 50 valid users OFFSET 0 500 users installed users 750 users friend 1000 users
  • 34. (2) !   friends n:m, user_app 1:n, users 1:1 !   friends ( 1000 ) user_app !   users SQL_CALC_FOUND_ROWS LIMIT, OFFSET !  friends !  Temporary Table INSERT users JOIN
  • 35. (1) !  ! selectall_arrayref !  !   SQL_CALC_FOUND_ROWS !   LIMIT, OFFSET COUNT(*) !  !   Temporary Table !  !  !  user_id user_id LIMIT, OFFSET
  • 36. (2) !   prepare, fetchall_arrayref($max_rows) !   DBI::st fetchall_arrayref($max_rows) $max_rows !  !  friends 1000 !  1000 users user_app !   1000 !  1000 users !  1000 ! 
  • 37. installed users valid users friend installed users 750 users 750 users 1000 users 1000 users installed users valid users 750 users 750 users friend installed users 1000 users 1000 users 100 users installed users 750 users installed users 250 users friend 1000 users end iteration
  • 38. (3) !  !  !   Iterator::GroupedRange ! http://search.cpan.org/dist/Iterator-GroupedRange/ !  List::MoreUtils natatime I::GR (fetchall_arrayref($max_rows) )
  • 39. (4) !  !   friends DB 1000 memcached get/set ! user_app mapping memcached ( install ) !  iteration DB DB iteration set !  3 !  xaicron
  • 40. (1) !  !  !  !  w !  kazuho
  • 41.
  • 42. !  !  !  !  !  !  xaicron !  !  !