Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ApcClassLoader

 ApcClassLoader

polidog

May 29, 2016
Tweet

More Decks by polidog

Other Decks in Technology

Transcript

  1. ApcClassLoader symfony meetup #12 @polidog

  2. ࣗݾ঺հ • @polidog • λϏΟίϜגࣜձࣾͰSymfonyॻ͍ͯ·͢ • ࠷ۙ͸BEARSundayษڧͯ͠·͢

  3. ApcClassLoaderʁ

  4. None
  5. ApcClassLoaderʁ • web/app.phpͰίϝϯτΞ΢τͯ͋͠Δ΍ͭ
 ͱࢥͬͨΒ࠷৽ͷSymfonyͩͱ࡟আ͞Εͯ ͨɾɾɾ • ͳͯ͘΋ಈ͘ • ͳΜͱͳ࣮͘ߦ଎౓͕ૣ͘ͳΓͦ͏

  6. ͱΓ͋͑ͣಈ͔ͯ͠ΈΑ͏

  7. apc(u)͕ඞཁͰ͢ɻ

  8. brew install php70-apcu

  9. web/app.phpΛฤू

  10. use Symfony\Component\ClassLoader\ApcClassLoader; $apcLoader = new ApcClassLoader(sha1(__FILE__), $loader);
 $loader->unregister();
 $apcLoader->register(true);


  11. ܭଌͯ͠Έͨ

  12. ܭଌ৚݅ • MacBook Pro (Retina, 15-inch, Mid 2014) 16GB Memory,

    2.2 GHz Intel Core i7 • php7.0.6 • ϏϧτΠϯαʔό࢖ͬͯΔ • ඵؒ10ϦΫΤετΛ5ඵִؒ • vegeta࢖ͬͯݕূ
 https://github.com/tsenart/vegeta
  13. ApcClassLoaderͳ͠

  14. $ echo "GET http://localhost:8000/" | vegeta attack -rate=50 - duration=5s

    | vegeta report
 
 Requests [total, rate] 50, 10.20
 Duration [total, attack, wait] 4.91808977s, 4.899999865s, 18.089905ms
 Latencies [mean, 50, 95, 99, max] 29.650298ms, 17.586892ms, 39.421233ms, 216.898977ms, 304.779713ms
 Bytes In [total, mean] 230050, 4601.00
 Bytes Out [total, mean] 0, 0.00
 Success [ratio] 100.00%
 Status Codes [code:count] 200:50
 Error Set:
  15. ApcClassLoader͋Γ

  16. $ echo "GET http://localhost:8000/" | vegeta attack -rate=50 - duration=5s

    | vegeta report
 
 Requests [total, rate] 50, 10.20
 Duration [total, attack, wait] 4.913044931s, 4.899999873s, 13.045058ms
 Latencies [mean, 50, 95, 99, max] 12.37756ms, 12.595445ms, 13.760764ms, 13.93599ms, 15.280703ms
 Bytes In [total, mean] 230050, 4601.00
 Bytes Out [total, mean] 0, 0.00
 Success [ratio] 100.00%
 Status Codes [code:count] 200:50
 Error Set:
  17. ApcClassLoaderૣ͍ʂʂʂ

  18. ApcClassLoader͸ԿΛͯ͠ ͍Δͷ͔ʁ

  19. ApcClassLoader͸ԿΛ͍ͯ͠ Δͷ͔ʁ • spl_autoload_registerʹApcClassLoaderͷloadClassϝιουΛొ࿥͠ ͍ͯΔ͚ͩ • findFileͰapcuʹΩϟογϡ͞Ε͍ͯͳ͚Ε͹ɺϑΝΠϧΛΩϟογϡ ͢ΔΑ͏ʹ͍ͯ͠Δ
 https://git.io/vrHLh •

    ௨ৗ͸PSRͷComposer\Autoload\ClassLoaderͷfindFile͕࣮ߦ͞Εͯ ͍ΔͷͰ஗͍ɻ
 https://git.io/vrHLN

  20. ·ͱΊ

  21. ·ͱΊ • ApcClassLoader͸ૣ͍ʂ • ϓϩμΫγϣϯͰ࢖ͬͨ΄͏͕ྑͦ͞͏ • ϝϞϦগͳ͍࣮ߦ؀ڥͩͱͪΐͬͱ৺഑
 (ࠓ౓ௐ΂Δʣ

  22. ͓͠·͍ɻ