Your SlideShare is downloading. ×
0
Serban Nicolae [email_address] <ul><li>Netbridge Development SRL </li></ul>APC - Alternative PHP Cache opcode cache
APC - Alternative PHP Cache <ul><li>Anatomia unui request php
APC </li><ul><li>Instalare
Facilitati oferite
Configurare
Teste </li></ul></ul>
APC - Alternative PHP Cache <ul>Anatomia unui request php </ul><?php $a = 1; $b = 2; $c = $a + $b; echo $c; ?> Exemplu: pl...
APC - Alternative PHP Cache Read Output Parse Compile Execute play.php <ul>Anatomia unui request php </ul>
APC - Alternative PHP Cache Output Parse Compile Execute play.php <ul>Anatomia unui request php </ul>Read Server API ( SAP...
APC - Alternative PHP Cache Output Compile Execute <ul>Anatomia unui request php </ul>Read Parsarea - Se parcurge codul su...
APC - Alternative PHP Cache <ul>Anatomia unui request php </ul><?php $a = 1; $b = 2; $c = $a + $b; echo $c; ?> T_OPEN_TAG ...
APC - Alternative PHP Cache Output Execute <ul>Anatomia unui request php </ul>Read Compilarea - Se face doar in cazul in c...
APC - Alternative PHP Cache Output Execute <ul>Anatomia unui request php </ul>Read Parse Compile Finding entry points Bran...
APC - Alternative PHP Cache Output Execute <ul>Anatomia unui request php </ul>Read Parse Compile Pentru fiecare fisier cod...
APC - Alternative PHP Cache Read Output Parse Compile Execute play.php Cache opcode PHP
APC - Alternative PHP Cache A lternative  P HP  C ache ( APC ) Este o extensie pentru php care  realizeaza cache pentru co...
Upcoming SlideShare
Loading in...5
×

Apc presentation

2,202

Published on

Apc php ext in romanian

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,202
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Apc presentation"

  1. 1. Serban Nicolae [email_address] <ul><li>Netbridge Development SRL </li></ul>APC - Alternative PHP Cache opcode cache
  2. 2. APC - Alternative PHP Cache <ul><li>Anatomia unui request php
  3. 3. APC </li><ul><li>Instalare
  4. 4. Facilitati oferite
  5. 5. Configurare
  6. 6. Teste </li></ul></ul>
  7. 7. APC - Alternative PHP Cache <ul>Anatomia unui request php </ul><?php $a = 1; $b = 2; $c = $a + $b; echo $c; ?> Exemplu: play.php
  8. 8. APC - Alternative PHP Cache Read Output Parse Compile Execute play.php <ul>Anatomia unui request php </ul>
  9. 9. APC - Alternative PHP Cache Output Parse Compile Execute play.php <ul>Anatomia unui request php </ul>Read Server API ( SAPI) - mod_php ( Apache 2) - FastCGI ( Lighttpd, Nginx ) - php-fpm ( Lighttpd, Nginx )
  10. 10. APC - Alternative PHP Cache Output Compile Execute <ul>Anatomia unui request php </ul>Read Parsarea - Se parcurge codul sursa si se genereaza o serie de token-uri pentru fiecare cuvant din codul sursa. - Se analizeaza token-urile si se determina structura lor gramaticala. - Se compara structura gramaticala cu cea definita in regulile de sintaxa ale limbajului. Parse Exemplu greseala de sintaxa: PHP Parse error: syntax error, unexpected T_VARIABLE in play.php on line 3
  11. 11. APC - Alternative PHP Cache <ul>Anatomia unui request php </ul><?php $a = 1; $b = 2; $c = $a + $b; echo $c; ?> T_OPEN_TAG :: <?php T_WHITESPACE :: T_VARIABLE :: $a = T_LNUMBER :: 1 T_WHITESPACE :: T_VARIABLE :: $b = T_LNUMBER :: 2 ; T_WHITESPACE :: T_VARIABLE :: $c = T_VARIABLE :: $a + T_VARIABLE :: $b ; T_WHITESPACE :: T_ECHO :: echo T_WHITESPACE :: T_VARIABLE :: $c ; T_WHITESPACE :: T_CLOSE_TAG :: ?> Parsare * Cu ajutorul functiilor PHP token_get_all(<STRING>) si token_name(<INT>)
  12. 12. APC - Alternative PHP Cache Output Execute <ul>Anatomia unui request php </ul>Read Compilarea - Se face doar in cazul in care nu exista greseli de sintaxa. - Generarea de bytecode ( numit opcode ) pe baza codului sursa. - Codul opcode este generat de catre Zend Engine - Rularea lui se face tot de catre Zend Engine Exemple de instructiuni opcode intelese de Zend Engine: NOP, ADD, DIV, IS_EQUAL, ASSIGN_ADD, CAST .... Lista completa: http://www.php.net/manual/en/internals2.opcodes.list.php Parse Compile
  13. 13. APC - Alternative PHP Cache Output Execute <ul>Anatomia unui request php </ul>Read Parse Compile Finding entry points Branch analysis from position: 0 Return found filename: /media/projects/play/public/play.php function name: (null) number of ops: 6 compiled vars: !0 = $a, !1 = $b, !2 = $c line # * op fetch ext return operands --------------------------------------------------------------------------------- 2 0 > ASSIGN !0, 1 3 1 ASSIGN !1, 2 4 2 ADD ~2 !0, !1 3 ASSIGN !2, ~2 5 4 ECHO !2 7 5 > RETURN 1 branch: # 0; line: 2- 7; sop: 0; eop: 5 OPCODE play.php * Cu ajutorul extensiei PHP Vulcan Logic Disassembler (VLD)
  14. 14. APC - Alternative PHP Cache Output Execute <ul>Anatomia unui request php </ul>Read Parse Compile Pentru fiecare fisier cod sursa php dintr-un proiect web se efectueaza parsarea si compilarea lui la fiecare cerere catre serverul web. Pe masinile de productie codul sursa al fisierelor se modifica foarte rar . Cum se poate imbunatatii timpul de executie ...
  15. 15. APC - Alternative PHP Cache Read Output Parse Compile Execute play.php Cache opcode PHP
  16. 16. APC - Alternative PHP Cache A lternative P HP C ache ( APC ) Este o extensie pentru php care realizeaza cache pentru codul intern al lui Zend Engine si anume opcode . Cachul este tinut in RAM. Instalarea se face cu ajutorul PECL pecl install apc Se configureaza cu ajutorul fisierului php.ini Se doreste introducerea extensiei in Core incepand cu PHP 6. Extensia ofera un set de functii pentru manevrarea cache-ului. Este dezvoltata de comunitatea php.net
  17. 17. APC - Alternative PHP Cache Facilitati oferite - opcode cache ( prin incarcarea extensiei ) - optimizarea codului opcode ( prin incarcarea extensiei ) - cache pentru continut ( date din DB ) ( prin functiile apc_add(), apc_store(), apc_fetch(), apc_delete() ) - acces la date in momentul cand se efectueaza un upload ( prin variabila APC_UPLOAD_PROGRESS )
  18. 18. APC - Alternative PHP Cache Exemplu de configurare in php.ini apc.enabled = On apc.stat = Off apc.shm_size = 30 apc.shm_segments = 1 apc.ttl = 0 apc.optimization = 3
  19. 19. APC - Alternative PHP Cache Teste Web site: http://www.serbanalexandru.ro Nginx 0.8.36 | PHP 5.3.2 | WordPress 2.9.2 Tool pentru testare Apache Benchmark (ab) ab -n 500 -c 10 http://www.serbanalexandru.ro/ CU APC Concurrency Level: 10 Time taken for tests: 59.218 seconds Complete requests: 500 Failed requests: 0 Write errors: 0 Total transferred: 15562500 bytes HTML transferred: 15449000 bytes Requests per second: 8.44 [#/sec] (mean) Time per request: 1184.353 [ms] (mean) Time per request: 118.435 [ms] (mean, across all concurrent requests) Transfer rate: 256.64 [Kbytes/sec] received FARA APC Concurrency Level: 10 Time taken for tests: 138.903 seconds Complete requests: 500 Failed requests: 0 Write errors: 0 Total transferred: 15562500 bytes HTML transferred: 15449000 bytes Requests per second: 3.60 [#/sec] (mean) Time per request: 2778.058 [ms] (mean) Time per request: 277.806 [ms] (mean, across all concurrent requests) Transfer rate: 109.41 [Kbytes/sec] received
  20. 20. APC - Alternative PHP Cache Va multumesc
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×