    
 


    ,    -.

        ( CAP  PACELC),       ,      .       ,    .           Serverless     ,    .

      (TCO)    ,     ,    .





 

    





 




   (High-Load).    :     (RPS),   ,   .

 :  ,  ,   .

    :        .

 1.     

 1.    

 CAP (Consistency, Availability, Partition tolerance):   (Consistency),  (Availability)     (Partition tolerance).         .

 PACELC:  CAP.    (Latency)   (Consistency)   .

FLP Impossibility ( ,   ):             .

     :      .

 2.  : , , 

 (Latency vs Throughput):        .      (  ).

 (Reliability)   (Availability):  .   (,   - 99.9%).      (MTBF)     (MTTR).

 :  (Strong),  (Causal)   (Eventual) .     (Read-Your-Writes).

 :

 :  -  .  -  .

  :  -     .  -   (    ).

 (Cost)   :       (CAPEX)   (OPEX) .

 3.   :     

  :            (     ).

 (Workarounds)     TCO:   :

      (Key-Value)  . :  ,    .

        . :  ,  .

   API. :     .

 :     (Strangler Fig Pattern,  ).

 2.    

 4. ,    

N+1, N+2, 2N, 2N+1:        .    .

  (Cold Standby):  ,   .   (RTO) - .   - . :    ,     .

  (Warm Standby):  ,    . RTO -  . : Slave- ,      .

  (Hot Standby): Active-Passive  Active-Active    . RTO - .   (failover).  -   .

 5.      (SRE-)

Error Budget ( ):   ,   SLA (Service Level Agreement).

Chaos Engineering (-):            .  (,       ).

GameDay ( ):    (  -,   CDN).    .     .

Post-mortem ( ):  .     (blameless culture),   .

 6.    (On-call)

 :   (L1),   (L2),    (L3).

   :   (, 12/24/72),  .

Runbooks (  ):     .       .

  : Signal-to-noise ratio.   (thresholds)    (anomaly detection)    .

 3.    

 7.   (Monolith)

:   ,   ,      .

:      ,    (ACID),       (IPC).

:    (Scale-Up),     ,   (tight coupling),    .

:        .

 8.   (N-Tier)

:      : Presentation (), Business Logic ( ), Data Access (  ), Data Storage ().

:  ,        .

:     (Big Ball of Mud)    ,      .

 9. -  (SOA)    (Microservices)

:        .  (REST, gRPC)   (Message Queue) .

:   (    ),     ,   (Scale-Out)  .

:     ,    (Saga, 2PC),  ,  ,  .

:    (  , , , ).

 10. -  (Event-Driven Architecture)   

:     (Apache Kafka, RabbitMQ).   ,    .

:   (decoupling),   (   ),     .

:   ,   end-to-end ,          .

 11. Serverless- (FaaS)

:         (AWS Lambda, Yandex Cloud Functions).    .

:   ,        .

:    (Cold Start),     (),     (vendor lock-in),   .

 4.    

 12.     (Total Cost of Ownership, TCO)

  (Direct Costs):

CAPEX:   ,  ,   .

OPEX:    (CPU, RAM, Storage, Egress-),   SaaS.

  (Indirect Costs):

  ( ,  , ).

  (Downtime Cost):     .

  (Cost of Change): ,    .

 :  TCO = CAPEX + (OPEX_ + OPEX_ + _) * __.

 :  TCO      (On-premise)         5 .

 13.      

 (Observability)  : , ,  (OpenTelemetry).    (Latency, Traffic, Errors, Saturation).

 : Infrastructure as Code (Terraform, Ansible),     (CI/CD).

 :   (Design Review)        (Decommissioning).



     :  - (SLA, ,    )   .

-       .



      (RPS, CAP, MTTR, Sharding, Idempotency  .)    ,    .







       ,    ,   ,   .                        .  ,   ,            ,        .                  ,     .

       ,     .    (High-Load)      - ,       (   :   ,   )        .

         : -,  ,       .    ,    ,      .   ,   ,       ,      .   ,     ,    -     -         .

 ,       ,   ,   -       ,    .    -            .      ( ),       (),          (TCO).

       .  CAP (Consistency, Availability, Partition Tolerance)       ,       .  PACELC   ,              ,    .             (   Go   )    ,     -     (SLA)    .

        .             .      (,      ,      )     -    -     ,         .    , ,          (TCO)       .

        .              ,   .       :   (,    ),        (Chaos Engineering).         -       - , -    ,    . ,  ,   :      (TCO),      ,     ,    ,   .

   -       ,      .        ,        ,              .




 1.     





 1.    


            ,       ,    .   -      (),          .         ,         .     ,      :  CAP,  PACELC   FLP.

1.1.  CAP ( )

 2000     ,   2002         .  CAP ,     ,      ,         :

 (Consistency, C):             .  ,               .     .

 (Availability, A):              (    ).      .

   (Partition Tolerance, P):        ( / )     .   (Partition) -  ,             -  ,    ,     .

 :     (Partition)      ,  P (Partition Tolerance)        (P = true). ,     C  A.     CA (  ,      -         ),  CP (    ,       ),  AP (    ,       ).

:

CP- (C + P):    (, PostgreSQL)    .  -    ,    ,     .  ,    (   ).

AP- (A + P):    (DNS)    - (, Apache Cassandra   ).    ,     ,   ,     .  ,      ( ).

1.2.  PACELC

 CAP        ( ).       :       ,    ?        PACELC ( -  ).     ,    :

Partition (): If there is a partition (  ),     Availability ()  Consistency ()?

Else (): In the absence of a partition (  ),     Latency ()  Consistency ()?

 ,       (P  )       (Latency),    (Consistency).

   C (),        ,     .         ,    (Latency).

   L ( ),    ,     ,      .    ,     .

:      .         C ().       ,     ,       .      200500  ( Latency),     .     .   L ().       ,         ,       .    ,    ,       .

1.3.  FLP Impossibility ( )

 1985   ,        ,    ()   .  :    ,            ,   ,        (,       ).

  :  -  ,          (,    ,     ).    .         ,     :    ,     ,      ?     .     ( )       ,      .

 :    ,          .   :

 :    ,     N ,     (     ).

    (Leader-based consensus):    Paxos  Raft.     (),     .             ,    () .



           CAP  PACELC.

      ,     C (Consistency),    A (Availability)    L (Latency)   .

       (,  ),     A (Availability)  L (Latency),      C (Consistency).

  FLP    ,    ,   ,       ,   .            ,             .




 2.  : , , 


         .         .            (  ,          ). ,             .       (),  ()   ( ).         .

2.1. :    

          :  (Latency)    (Throughput).

 (Latency):              .     ( ms,  mks).    .      L_total       : L_total = L_network + L_queue + L_processing + L_disk  L_network -     , L_queue -     , L_processing -   CPU, L_disk -  -.

  (Throughput):    (, , ),       .      (RPS - Requests Per Second)     (bps).

:            .     (First-In-First-Out)      ,        .   (Batching)   1000       -,      .    1000    ,   ,      .

2.2.   

          .

 (Reliability):  ,              .   MTBF (Mean Time Between Failures -     ).    .

 (Availability):  ,            .    A: A = MTBF / (MTBF + MTTR),  MTTR (Mean Time To Repair) -   .

   ,  . : ,      . MTTR  1 ,     100%,    ,      (MTBF ).

:      (),      4.            ,    ,   MTTR      (SPOF - Single Point of Failure).

2.3.  

 ,           .

  (Strong Consistency):               .       ,    .

  (Eventual Consistency):       ,   ( )        .          ,    .      .

:       -     PACELC. :    (   )   .    ,            .       ,      . :        .      ,     2 ,      .                ,    .

2.4.    

 1:    

:   ,    .

:  -  (C)   (Reliability).

:    (,  Saga     2PC).       .

 :   (   12 )          ( ).   (TCO)  -     .

 2:    ( )

:   ,    .

:  -  (L)   (A).

:     (Message Queue),       (,  Redis).   .

 :     ,          510 .             ,     .




  .


   .

   ,     (https://www.litres.ru/book/georgiy-dimitriadi/rukovodstvo-po-sozdaniiu-vysokonagruzhennykh-sistem-74604414/)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


