SlideShare une entreprise Scribd logo
1  sur  24
Erlang and
              Scalability
         Percona Performance 2009



Jan Henry Nystrom
henry@erlang-consulting.com
Introduction
•     Scalability Killers
•     Design Decisions – Language and Yours
•     Thinking Scalable/Parallel
•     Code for the correct case
•     Rules of Thumb
•     Scalability in the small: SMP




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   2
Scalability Killers
• Synchronization
• Resource contention
  Synchronization




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   3
Design Decisions
                                               No sharing

• Processes
• Encapsulation
• No implicit synchronization




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   4
Design Decisions
                         No implicit synchronization

•     Spawn always succeed
•     Sending always succeed
•     Random access message buffer
•     Fire and forget unless you need the synchronization




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   5
Design Decisions
              Concurrency oriented programming

•     Concurrency support an integral part of the language
•     Distribution support
•     Sets the focus firmly on the concurrent tasks
•     Code for the correct case
•     Clear Code


                                      Clarity is King!
        I rather try to get clear code correct than correct code clear


Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   6
Thinking Scalable/Parallel
                         List length: Obviously Linear

      4
      3
      2
      1
      0:




                         But not when you have n processors?


Erlang and Scalability    Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   7
Thinking Scalable/Parallel
 List length: O(logN) with sufficient processors

          4


           2                                                        2


           1                           1                             1                             1




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   8
Thinking Scalable/Parallel
                                 In the Erlang setting

•     Do not introduce unneeded synchronization
•     Remember processes are cheap
•     Do not introduce unneeded synchronization
•     A terminated process is all garbage
•     Do not introduce unneeded synchronization




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   9
Code for the Correct Case


                                     request
        set timer
                                          set timer                      request
                                                                                                        request
                                                                            set timer
                                                                                                            r
                                                                                                   answe

                                                                    release timer
                                                                            check
                                                                a n sw er

                                release timer
                                  w er  check
                             a ns

release timer
        check
 Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting             10
Code for the Correct Case


                                    request
       set timer
                                                                        request
                                                                                                       request



                                            r
                                 answe
release timer
        check




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting             11
Rules of Thumb
• Rule 1 - All independent tasks should be processes
• Rule 2 - Do not invent concurrency that is not there!



                            f()



                            g()
                                                                    h(g(f()))
                                                                       h(g(f()))
                                                                           h(g(f()))
                                                                              h(g(f()))
                            h()




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   12
Scalability in the small: SMP
                                   Erlang SMP ”Credo”


 SMP should be transparent to the programmer in
    much the same way as Erlang Distribution

• You shouldn’t have to think about it
   ...but sometimes you must
• Use SMP mainly for stuff that you’d make concurrent anyway
• Erlang uses concurrency as a structuring principle
  • Model for the natural concurrency in your problem




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   13
Scalability in the small: SMP
                                                                        ”Big bang” benchmark on Sunfire T2000
• Erlang on multicore

                                                                                            1 scheduler
• SMP prototype ‘97,
  First OTP release May ‘06.
• Mid -06 benchmark mimicking
  call handling (axdmark) on the
  (experimental) SMP emulator.
  Observed speedup/core: 0.95
• First Ericsson product (TGC)
  released on SMP Erlang
  in Q207.
                                                                                                          16 schedulers
                                                                                 Simultaneous processes



Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting             14
Scalability in the small: SMP
   Case Study: Telephony Gateway Controller

                                                                             AXE                       TGC

• Mediates between legacy telephony and multimedia
  networks.
• Hugely complex state machines
• + massive concurrency.                        GW GW                                                    GW
• Developed in Erlang.
• Multicore version shipped to customer Q207.
• Porting from 1-core PPC to 2-core Intel took < 1 man-year
  (including testing).

Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting     15
Scalability in the small: SMP
   Case Study: Telephony Gateway Controller
       Traffic            IS/GCP                 IS/GEP                   IS/GEP                AXD          AXD
      scenario
                          1slot/board          Dual core                 Dual core              CPB5         CPB6
                                               One core                  Two cores
                                                running                   running
                                              2slots/board              2slots/board


    POTS-POTS             X call/sec         2.3X call/sec           4.3X call/sec               0.4X      2.1X call/sec
      /AGW
                                                                        OTP R11_3               call/sec
                                             One core used
                                                                      beta+patches

  ISUP-ISUP /Inter       3.6X call/sec 7.7X call/sec                  13X call/sec               1.55X     7.6X call/sec
      MGW
                                                                        OTP R11_3               call/sec
                                             One core used
                                                                      beta+patches

  ISUP-ISUP /Intra       5.5X call/sec                                  26X call/sec             3.17X     14X call/sec
      MGW
                                                                                                call/sec


Erlang and Scalability    Percona Performance Conference © 2009 -2009, Erlang Training and Consulting               16
Scalability in the small: SMP
                                               Speedup on 4 Hyper Threaded Pentium4

                                         4.5
                                          4                                                                                3.96
                                                                                                                    3.79
                                         3.5                                                             3.63

                               Speddup    3                                                   3.11
                                                                                   2.73
                                         2.5
                                          2                  1.92       2.05

                                         1.5
                                          1          1
                                         0.5
                                          0
                                                 1       2          3          4          5          6          7          8

• Chatty                                                                  # Schedulers


• 1000 processes created
• Each process randomly sends req/recieves ack from all other
  processes
Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting                           17
Scalability in the small: SMP
                                                    Erlang VM
non-SMP VM
                                                                                                run queue



                                               Scheduler




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting        18
Scalability in the small: SMP
                                                       Erlang VM
Current SMP VM
                                                                                                   run queue
 OTP R11/R12                                      Scheduler #1



                                                Scheduler #2




                                            Scheduler #N



 Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting          19
Scalability in the small: SMP
                                             Erlang VM
New SMP VM
  OTP R13                                  Scheduler #1 run queue

    Released
    21th April                                                                                         migration
                                       Scheduler #2                         run queue                    logic




                                      Scheduler #N                          run queue



Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting               20
Scalability in the small: SMP
                                          Multiple
                                         run queues



                                                          Speedup: Ca 0.43 * N @ 32 cores
                                                                               Memory allocation locks
                                                                                   dominate...


                                                    Single
                                                  run queue




• Speedup of ”Big Bang” on a Tilera Tile64 chip (R13A)
  • 1000 processes, all talking to each other
 Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting    21
Scalability in the small: SMP
                                  Shift in Bottlenecks

• All scalable Erlang systems were stress tested
    for CPU usage
    for network usage
• With SMP hardware we must stress test for memory usage
• In the typical SMP system, the bottleneck has shifted from
  the CPU to the memory




Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   22
Scalability in the small: SMP
                          Death by a thousand cuts

• Many requests that generate short spikes in memory usage
• Limit or serialize those requests
• More on this in coming paper from CTO Ulf Wiger

loop(State) ->
  receive
   {request, typeA, Data} ->
       Data1 = allocate_lots_of_memory(Data),
        a_server ! {request, typeA, self()},
      receive
          {answer, …

Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   23
Questions




                                                   ???


Erlang and Scalability   Percona Performance Conference © 2009 -2009, Erlang Training and Consulting   24

Contenu connexe

Tendances

Integrating Proof and Testing in Verification Strategies for Safety Critical ...
Integrating Proof and Testing in Verification Strategies for Safety Critical ...Integrating Proof and Testing in Verification Strategies for Safety Critical ...
Integrating Proof and Testing in Verification Strategies for Safety Critical ...AdaCore
 
Large customers want postgresql too !!
Large customers want postgresql too !!Large customers want postgresql too !!
Large customers want postgresql too !!rosensteel
 
Re usable continuous-time analog sva assertions - slides
Re usable continuous-time analog sva assertions - slidesRe usable continuous-time analog sva assertions - slides
Re usable continuous-time analog sva assertions - slidesRégis SANTONJA
 
Advancing OpenFabrics Interfaces
Advancing OpenFabrics InterfacesAdvancing OpenFabrics Interfaces
Advancing OpenFabrics Interfacesinside-BigData.com
 
New integrations for synergy and change - Sean Innes
New integrations for synergy and change - Sean InnesNew integrations for synergy and change - Sean Innes
New integrations for synergy and change - Sean InnesRoopa Nadkarni
 
Multi stage filtering process diagram 11 stages proto typing power point temp...
Multi stage filtering process diagram 11 stages proto typing power point temp...Multi stage filtering process diagram 11 stages proto typing power point temp...
Multi stage filtering process diagram 11 stages proto typing power point temp...SlideTeam.net
 

Tendances (8)

Integrating Proof and Testing in Verification Strategies for Safety Critical ...
Integrating Proof and Testing in Verification Strategies for Safety Critical ...Integrating Proof and Testing in Verification Strategies for Safety Critical ...
Integrating Proof and Testing in Verification Strategies for Safety Critical ...
 
Large customers want postgresql too !!
Large customers want postgresql too !!Large customers want postgresql too !!
Large customers want postgresql too !!
 
Khan and morrison_dq207
Khan and morrison_dq207Khan and morrison_dq207
Khan and morrison_dq207
 
Re usable continuous-time analog sva assertions - slides
Re usable continuous-time analog sva assertions - slidesRe usable continuous-time analog sva assertions - slides
Re usable continuous-time analog sva assertions - slides
 
Advancing OpenFabrics Interfaces
Advancing OpenFabrics InterfacesAdvancing OpenFabrics Interfaces
Advancing OpenFabrics Interfaces
 
New integrations for synergy and change - Sean Innes
New integrations for synergy and change - Sean InnesNew integrations for synergy and change - Sean Innes
New integrations for synergy and change - Sean Innes
 
Multi stage filtering process diagram 11 stages proto typing power point temp...
Multi stage filtering process diagram 11 stages proto typing power point temp...Multi stage filtering process diagram 11 stages proto typing power point temp...
Multi stage filtering process diagram 11 stages proto typing power point temp...
 
Eigrp
EigrpEigrp
Eigrp
 

Similaire à Erlang and Scalability

Erlang workshopdrammen
Erlang workshopdrammenErlang workshopdrammen
Erlang workshopdrammenReidar Sollid
 
Thinking in a Highly Concurrent, Mostly-functional Language - Cesarini
Thinking in a Highly Concurrent, Mostly-functional Language - CesariniThinking in a Highly Concurrent, Mostly-functional Language - Cesarini
Thinking in a Highly Concurrent, Mostly-functional Language - CesariniCodemotion
 
The design and implementation of a scalable concurrent virtual machine (Rober...
The design and implementation of a scalable concurrent virtual machine (Rober...The design and implementation of a scalable concurrent virtual machine (Rober...
The design and implementation of a scalable concurrent virtual machine (Rober...Ontico
 
Graal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution PlatformGraal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution PlatformThomas Wuerthinger
 
The design and implementation of a scalable concurrent virtual machine (Rober...
The design and implementation of a scalable concurrent virtual machine (Rober...The design and implementation of a scalable concurrent virtual machine (Rober...
The design and implementation of a scalable concurrent virtual machine (Rober...Ontico
 
Intel's Nehalem Microarchitecture by Glenn Hinton
Intel's Nehalem Microarchitecture by Glenn HintonIntel's Nehalem Microarchitecture by Glenn Hinton
Intel's Nehalem Microarchitecture by Glenn Hintonparallellabs
 
Nashorn in the future (English)
Nashorn in the future (English)Nashorn in the future (English)
Nashorn in the future (English)Logico
 
Which Is Deeper - Comparison Of Deep Learning Frameworks On Spark
 Which Is Deeper - Comparison Of Deep Learning Frameworks On Spark Which Is Deeper - Comparison Of Deep Learning Frameworks On Spark
Which Is Deeper - Comparison Of Deep Learning Frameworks On SparkSpark Summit
 
You got ur Erlang in my Ruby
You got ur Erlang in my RubyYou got ur Erlang in my Ruby
You got ur Erlang in my Rubyelliando dias
 
Bringing complex event processing to Spark streaming
Bringing complex event processing to Spark streamingBringing complex event processing to Spark streaming
Bringing complex event processing to Spark streamingDataWorks Summit
 
Introduction To Perl - SpringPeople
Introduction To Perl - SpringPeopleIntroduction To Perl - SpringPeople
Introduction To Perl - SpringPeopleSpringPeople
 
Erlang及其应用
Erlang及其应用Erlang及其应用
Erlang及其应用Feng Yu
 
introductiontoperl-springpeople-150605065831-lva1-app6891.pptx
introductiontoperl-springpeople-150605065831-lva1-app6891.pptxintroductiontoperl-springpeople-150605065831-lva1-app6891.pptx
introductiontoperl-springpeople-150605065831-lva1-app6891.pptxmayilcebrayilov15
 
EEQA and EHM Background
EEQA and EHM BackgroundEEQA and EHM Background
EEQA and EHM Backgroundcrispieg
 
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex EnvironmentsDr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex EnvironmentsAgileSparks
 
Apache Big Data Europe 2016
Apache Big Data Europe 2016Apache Big Data Europe 2016
Apache Big Data Europe 2016Tim Ellison
 

Similaire à Erlang and Scalability (20)

Erlang workshopdrammen
Erlang workshopdrammenErlang workshopdrammen
Erlang workshopdrammen
 
Thinking in a Highly Concurrent, Mostly-functional Language - Cesarini
Thinking in a Highly Concurrent, Mostly-functional Language - CesariniThinking in a Highly Concurrent, Mostly-functional Language - Cesarini
Thinking in a Highly Concurrent, Mostly-functional Language - Cesarini
 
The design and implementation of a scalable concurrent virtual machine (Rober...
The design and implementation of a scalable concurrent virtual machine (Rober...The design and implementation of a scalable concurrent virtual machine (Rober...
The design and implementation of a scalable concurrent virtual machine (Rober...
 
Graal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution PlatformGraal VM: Multi-Language Execution Platform
Graal VM: Multi-Language Execution Platform
 
The design and implementation of a scalable concurrent virtual machine (Rober...
The design and implementation of a scalable concurrent virtual machine (Rober...The design and implementation of a scalable concurrent virtual machine (Rober...
The design and implementation of a scalable concurrent virtual machine (Rober...
 
Erlang os
Erlang osErlang os
Erlang os
 
Erlangfactory
ErlangfactoryErlangfactory
Erlangfactory
 
Intel's Nehalem Microarchitecture by Glenn Hinton
Intel's Nehalem Microarchitecture by Glenn HintonIntel's Nehalem Microarchitecture by Glenn Hinton
Intel's Nehalem Microarchitecture by Glenn Hinton
 
Nashorn in the future (English)
Nashorn in the future (English)Nashorn in the future (English)
Nashorn in the future (English)
 
Which Is Deeper - Comparison Of Deep Learning Frameworks On Spark
 Which Is Deeper - Comparison Of Deep Learning Frameworks On Spark Which Is Deeper - Comparison Of Deep Learning Frameworks On Spark
Which Is Deeper - Comparison Of Deep Learning Frameworks On Spark
 
Erlang at Nu Echo
Erlang at Nu EchoErlang at Nu Echo
Erlang at Nu Echo
 
You got ur Erlang in my Ruby
You got ur Erlang in my RubyYou got ur Erlang in my Ruby
You got ur Erlang in my Ruby
 
Bringing complex event processing to Spark streaming
Bringing complex event processing to Spark streamingBringing complex event processing to Spark streaming
Bringing complex event processing to Spark streaming
 
Introduction To Perl - SpringPeople
Introduction To Perl - SpringPeopleIntroduction To Perl - SpringPeople
Introduction To Perl - SpringPeople
 
Erlang及其应用
Erlang及其应用Erlang及其应用
Erlang及其应用
 
Efficiency and turnaround management
Efficiency and turnaround managementEfficiency and turnaround management
Efficiency and turnaround management
 
introductiontoperl-springpeople-150605065831-lva1-app6891.pptx
introductiontoperl-springpeople-150605065831-lva1-app6891.pptxintroductiontoperl-springpeople-150605065831-lva1-app6891.pptx
introductiontoperl-springpeople-150605065831-lva1-app6891.pptx
 
EEQA and EHM Background
EEQA and EHM BackgroundEEQA and EHM Background
EEQA and EHM Background
 
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex EnvironmentsDr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
Dr. Ronen Bar-Nahor - Optimizing Agile Testing in Complex Environments
 
Apache Big Data Europe 2016
Apache Big Data Europe 2016Apache Big Data Europe 2016
Apache Big Data Europe 2016
 

Dernier

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Dernier (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Erlang and Scalability

  • 1. Erlang and Scalability Percona Performance 2009 Jan Henry Nystrom henry@erlang-consulting.com
  • 2. Introduction • Scalability Killers • Design Decisions – Language and Yours • Thinking Scalable/Parallel • Code for the correct case • Rules of Thumb • Scalability in the small: SMP Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 2
  • 3. Scalability Killers • Synchronization • Resource contention Synchronization Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 3
  • 4. Design Decisions No sharing • Processes • Encapsulation • No implicit synchronization Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 4
  • 5. Design Decisions No implicit synchronization • Spawn always succeed • Sending always succeed • Random access message buffer • Fire and forget unless you need the synchronization Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 5
  • 6. Design Decisions Concurrency oriented programming • Concurrency support an integral part of the language • Distribution support • Sets the focus firmly on the concurrent tasks • Code for the correct case • Clear Code Clarity is King! I rather try to get clear code correct than correct code clear Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 6
  • 7. Thinking Scalable/Parallel List length: Obviously Linear 4 3 2 1 0: But not when you have n processors? Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 7
  • 8. Thinking Scalable/Parallel List length: O(logN) with sufficient processors 4 2 2 1 1 1 1 Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 8
  • 9. Thinking Scalable/Parallel In the Erlang setting • Do not introduce unneeded synchronization • Remember processes are cheap • Do not introduce unneeded synchronization • A terminated process is all garbage • Do not introduce unneeded synchronization Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 9
  • 10. Code for the Correct Case request set timer set timer request request set timer r answe release timer check a n sw er release timer w er check a ns release timer check Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 10
  • 11. Code for the Correct Case request set timer request request r answe release timer check Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 11
  • 12. Rules of Thumb • Rule 1 - All independent tasks should be processes • Rule 2 - Do not invent concurrency that is not there! f() g() h(g(f())) h(g(f())) h(g(f())) h(g(f())) h() Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 12
  • 13. Scalability in the small: SMP Erlang SMP ”Credo” SMP should be transparent to the programmer in much the same way as Erlang Distribution • You shouldn’t have to think about it ...but sometimes you must • Use SMP mainly for stuff that you’d make concurrent anyway • Erlang uses concurrency as a structuring principle • Model for the natural concurrency in your problem Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 13
  • 14. Scalability in the small: SMP ”Big bang” benchmark on Sunfire T2000 • Erlang on multicore 1 scheduler • SMP prototype ‘97, First OTP release May ‘06. • Mid -06 benchmark mimicking call handling (axdmark) on the (experimental) SMP emulator. Observed speedup/core: 0.95 • First Ericsson product (TGC) released on SMP Erlang in Q207. 16 schedulers Simultaneous processes Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 14
  • 15. Scalability in the small: SMP Case Study: Telephony Gateway Controller AXE TGC • Mediates between legacy telephony and multimedia networks. • Hugely complex state machines • + massive concurrency. GW GW GW • Developed in Erlang. • Multicore version shipped to customer Q207. • Porting from 1-core PPC to 2-core Intel took < 1 man-year (including testing). Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 15
  • 16. Scalability in the small: SMP Case Study: Telephony Gateway Controller Traffic IS/GCP IS/GEP IS/GEP AXD AXD scenario 1slot/board Dual core Dual core CPB5 CPB6 One core Two cores running running 2slots/board 2slots/board POTS-POTS X call/sec 2.3X call/sec 4.3X call/sec 0.4X 2.1X call/sec /AGW OTP R11_3 call/sec One core used beta+patches ISUP-ISUP /Inter 3.6X call/sec 7.7X call/sec 13X call/sec 1.55X 7.6X call/sec MGW OTP R11_3 call/sec One core used beta+patches ISUP-ISUP /Intra 5.5X call/sec 26X call/sec 3.17X 14X call/sec MGW call/sec Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 16
  • 17. Scalability in the small: SMP Speedup on 4 Hyper Threaded Pentium4 4.5 4 3.96 3.79 3.5 3.63 Speddup 3 3.11 2.73 2.5 2 1.92 2.05 1.5 1 1 0.5 0 1 2 3 4 5 6 7 8 • Chatty # Schedulers • 1000 processes created • Each process randomly sends req/recieves ack from all other processes Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 17
  • 18. Scalability in the small: SMP Erlang VM non-SMP VM run queue Scheduler Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 18
  • 19. Scalability in the small: SMP Erlang VM Current SMP VM run queue OTP R11/R12 Scheduler #1 Scheduler #2 Scheduler #N Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 19
  • 20. Scalability in the small: SMP Erlang VM New SMP VM OTP R13 Scheduler #1 run queue Released 21th April migration Scheduler #2 run queue logic Scheduler #N run queue Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 20
  • 21. Scalability in the small: SMP Multiple run queues Speedup: Ca 0.43 * N @ 32 cores Memory allocation locks dominate... Single run queue • Speedup of ”Big Bang” on a Tilera Tile64 chip (R13A) • 1000 processes, all talking to each other Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 21
  • 22. Scalability in the small: SMP Shift in Bottlenecks • All scalable Erlang systems were stress tested  for CPU usage  for network usage • With SMP hardware we must stress test for memory usage • In the typical SMP system, the bottleneck has shifted from the CPU to the memory Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 22
  • 23. Scalability in the small: SMP Death by a thousand cuts • Many requests that generate short spikes in memory usage • Limit or serialize those requests • More on this in coming paper from CTO Ulf Wiger loop(State) -> receive {request, typeA, Data} -> Data1 = allocate_lots_of_memory(Data), a_server ! {request, typeA, self()}, receive {answer, … Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 23
  • 24. Questions ??? Erlang and Scalability Percona Performance Conference © 2009 -2009, Erlang Training and Consulting 24