尊龙凯时人生就是搏

ÔõÑùʹÓÃDocker¾ÙÐÐÈÝÆ÷µÄÐÔÄܲâÊÔºÍѹÁ¦²âÊÔ

ÔõÑùʹÓÃDocker¾ÙÐÐÈÝÆ÷µÄÐÔÄܲâÊÔºÍѹÁ¦²âÊÔ £¬ÐèÒªÏêϸ´úÂëʾÀý

СÐò

ÈÝÆ÷ÐéÄ⻯ÊÖÒÕµÄÐËÆðʹµÃÓ¦ÓóÌÐòµÄ°²ÅźÍÔËÐÐÔ½·¢ÎÞаºÍ¸ßЧ £¬ÆäÖÐ×îÊܽӴýµÄ¹¤¾ßÖ®Ò»¾ÍÊÇ Docker¡£×÷ΪһÖÖÇáÁ¿¼¶µÄÈÝÆ÷»¯Æ½Ì¨ £¬Docker ÌṩÁËÒ»ÖÖÀû±ãµÄ·½·¨À´´ò°ü¡¢·Ö·¢ºÍÔËÐÐÓ¦ÓóÌÐò £¬¿ÉÊÇÔõÑù¶ÔÈÝÆ÷µÄÐÔÄܾÙÐвâÊÔºÍÆÀ¹À £¬ÌØÊâÊÇÔڸ߸ºÔØÇéÐÎϵÄѹÁ¦²âÊÔ £¬ÊÇÐí¶àÈËÌåÌùµÄÎÊÌâ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓà Docker ¾ÙÐÐÈÝÆ÷µÄÐÔÄܲâÊÔºÍѹÁ¦²âÊÔ £¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¹©²Î¿¼¡£

ÐÔÄܲâÊÔ

ÐÔÄܲâÊÔÊÇÆÀ¹ÀÈÝÆ÷ÔÚ²î±ð¸ºÔØÇéÐÎϵÄÌåÏÖºÍÐÔÄܵÄÀú³Ì¡£ÒÔÏÂÊÇһЩ³£¼ûµÄÐÔÄܲâÊÔÖ¸±ê£º

Æô¶¯Ê±¼ä£º´ÓÆô¶¯ÈÝÆ÷µ½ÈÝÆ÷¿ÉÓõÄʱ¼ä¡£

×ÊԴʹÓÃÂÊ£º°üÀ¨ CPU¡¢ÄÚ´æ¡¢´ÅÅ̺ÍÍøÂçµÈ×ÊÔ´µÄʹÓÃÂÊ¡£

ÍÌÍÂÁ¿£ºÌåÏÖÈÝÆ÷ÔÚµ¥Î»Ê±¼äÄÚ´¦ÀíµÄÇëÇóÊýÄ¿¡£

ÏìӦʱ¼ä£ºÌåÏÖÈÝÆ÷´¦ÀíÇëÇóËùÐèµÄʱ¼ä¡£

²¢·¢ÐÔÄÜ£ºÈÝÆ÷ͬʱ´¦Àí²¢·¢ÇëÇóµÄÄÜÁ¦¡£

ÈÝÆ÷ÐÔÄܲâÊԼƻ®

ΪÁ˾ÙÐÐÈÝÆ÷ÐÔÄܲâÊÔ £¬ÎÒÃÇÐèҪ׼±¸Ò»¸ö²âÊÔÇéÐÎ £¬ÆäÖаüÀ¨ÒÔÏÂ×é¼þ£º

Docker ÇéÐΣº×°ÖúÍÉèÖà Docker £¬°ü¹ÜÆäÕý³£ÔËÐС£

²âÊÔ¾µÏñ£º¹¹½¨Ò»¸öÊʺϾÙÐÐÐÔÄܲâÊԵľµÏñ £¬¿ÉÒÔʹÓÃÀàËÆÓÚ Apache Benchmark (ab) »òÊÇ JMeter µÈ¹¤¾ß¾ÙÐвâÊÔ¡£

ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʾÀý £¬ÑÝʾÔõÑùʹÓà Apache Benchmark ¾ÙÐÐÈÝÆ÷µÄÐÔÄܲâÊÔ¡£

ÇéÐÎ×¼±¸

Ê×ÏÈ £¬ÎÒÃÇÐèҪװÖà Docker ºÍ Apache Benchmark ¹¤¾ß¡£¼ÙÉèÒѾ­ÔÚ Linux ϵͳÉÏ×°ÖÃÁË Docker £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî×°Öà Apache Benchmark:

sudo apt-get install apache2-utils

µÇ¼ºó¸´ÖÆ

¹¹½¨²âÊÔ¾µÏñ

½¨ÉèÒ»¸öÃûΪ perf-test µÄÎļþ¼Ð £¬ÄÚÀï°üÀ¨Ò»¸ö¼òÆ Dockerfile Îļþ £¬ÄÚÈÝÈçÏ£º

FROM ubuntu:latest

RUN apt-get update && 
    apt-get install -y apache2 
    && apt-get clean 
    && rm -rf /var/lib/apt/lists/*

EXPOSE 80

CMD ["apache2ctl", "-D", "FOREGROUND"]

µÇ¼ºó¸´ÖÆ

È»ºó £¬ÔÚÖÕ¶ËÖнøÈë perf-test Îļþ¼Ð £¬²¢Ê¹ÓÃÒÔÏÂÏÂÁî¹¹½¨¾µÏñ£º

docker build -t perf-test .

µÇ¼ºó¸´ÖÆ

¹¹½¨Íê±Ïºó £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉó²é¾µÏñÊÇ·ñ½¨ÉèÀֳɣº

docker images

µÇ¼ºó¸´ÖÆ

ÔËÐÐÈÝÆ÷²¢²âÊÔÐÔÄÜ

½ÓÏÂÀ´ £¬ÎÒÃÇÐèÒªÔËÐÐÈÝÆ÷²¢¾ÙÐÐÐÔÄܲâÊÔ¡£Ê×ÏÈ £¬Ê¹ÓÃÒÔÏÂÏÂÁîÔËÐÐÈÝÆ÷£º

docker run -d -p 8080:80 --name perf-container perf-test

µÇ¼ºó¸´ÖÆ

Õ⽫ÔÚºǫ́ÔËÐÐÒ»¸öÃûΪ perf-container µÄÈÝÆ÷ £¬²¢½«ÈÝÆ÷µÄ 80 ¶Ë¿ÚÓ³Éäµ½Ö÷»úµÄ 8080 ¶Ë¿ÚÉÏ¡£

È»ºó £¬Ê¹ÓÃÒÔÏÂÏÂÁî²âÊÔÈÝÆ÷µÄÐÔÄÜ£º

ab -c 10 -n 1000 http://localhost:8080/

µÇ¼ºó¸´ÖÆ

Õ⽫·¢ËÍ 1000 ¸öÇëÇóµ½ÈÝÆ÷µÄµØµã £¬²¢ÒÔÿ´Î²¢·¢ 10 ¸öÇëÇóµÄ·½·¨¾ÙÐС£²âÊÔ¿¢Êºó £¬½«Êä³ö°üÀ¨ÁËÖÖÖÖÐÔÄÜÖ¸±êµÄЧ¹û¡£

ѹÁ¦²âÊÔ

ѹÁ¦²âÊÔÊÇÆÀ¹ÀÈÝÆ÷Ôڸ߸ºÔØÇéÐÎϵÄÌåÏÖºÍÎȹÌÐÔµÄÀú³Ì £¬Í¨¹ýÄ£Äâ¶àÓû§Í¬Ê±»á¼ûÈÝÆ÷À´ÊÓ²ìÆäÏìÓ¦ÇéÐκÍÐÔÄÜÌåÏÖ¡£

ÈÝÆ÷ѹÁ¦²âÊԼƻ®

ΪÁ˾ÙÐÐÈÝÆ÷ѹÁ¦²âÊÔ £¬ÎÒÃÇÐèҪ׼±¸Ò»¸ö²âÊÔÇéÐÎ £¬ÆäÖаüÀ¨ÒÔÏÂ×é¼þ£º

Docker ÇéÐΣº×°ÖúÍÉèÖà Docker £¬°ü¹ÜÆäÕý³£ÔËÐС£

ѹÁ¦²âÊÔ¹¤¾ß£ºÑ¡ÔñÊʺϵÄѹÁ¦²âÊÔ¹¤¾ß £¬Èç JMeter¡¢Gatling µÈ¡£

Ä¿µÄÈÝÆ÷£ºÔËÐдý²âÊÔµÄÈÝÆ÷ £¬²¢È·±£ÆäÕý³£ÔËÐкͻá¼û¡£

ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʾÀý £¬ÑÝʾÔõÑùʹÓà JMeter ¾ÙÐÐÈÝÆ÷µÄѹÁ¦²âÊÔ¡£

ÇéÐÎ×¼±¸

Ê×ÏÈ £¬ÎÒÃÇÐèҪװÖà Docker ºÍ JMeter ¹¤¾ß¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî×°Öà JMeter£º

sudo apt-get install jmeter

µÇ¼ºó¸´ÖÆ

½¨Éè²âÊԾ籾

ÔÚ JMeter ÖÐ £¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸ö²âÊÔÍýÏë £¬ÆäÖаüÀ¨Á˲âÊÔÏß³Ì×é¡¢ÇëÇóºÍЧ¹ûÆÊÎöÆ÷µÈ×é¼þ¡£

·­¿ª JMeter £¬Ñ¡Ôñ “Test Plan” £¬ÓÒ¼üµ¥»÷Ñ¡Ôñ “Add” -> “Threads (Users)” -> “Thread Group”¡£

ÔÚ “Thread Group” ÖÐÌîÈë²âÊÔ²ÎÊý £¬ÈçÏß³ÌÊý¡¢Ñ­»·´ÎÊýµÈ¡£

ÓÒ¼üµ¥»÷ “Thread Group” £¬Ñ¡Ôñ “Add” -> “Sampler” -> “HTTP Request” £¬ÔÚ “HTTP Request” ÖÐÌîÈë´ý²âÊÔÈÝÆ÷µÄµØµãºÍ¶Ë¿Ú¡£

ÓÒ¼üµ¥»÷ “Thread Group” £¬Ñ¡Ôñ “Add” -> “Listener” -> “View Results in Table”¡£

ÉúÑIJâÊÔÍýÏë¡£

ÔËÐÐѹÁ¦²âÊÔ

½ÓÏÂÀ´ £¬ÎÒÃÇÐèÒªÔËÐÐѹÁ¦²âÊÔ¡£Ê×ÏÈ £¬Ê¹ÓÃÒÔÏÂÏÂÁîÔËÐдý²âÊÔµÄÈÝÆ÷£º

docker run -d -p 8080:80 --name stress-container perf-test

µÇ¼ºó¸´ÖÆ

½Ó×Å £¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÔËÐÐ JMeter ²âÊÔÍýÏ룺

jmeter -n -t <²âÊÔÍýÏëÎļþ> -l <Ч¹ûÎļþ>

µÇ¼ºó¸´ÖÆ

ÔËÐп¢Êºó £¬¿ÉÒÔͨ¹ýЧ¹ûÎļþÀ´Éó²éѹÁ¦²âÊÔµÄЧ¹ûºÍÐÔÄÜÖ¸±ê¡£

½áÂÛ

±¾ÎÄÏÈÈÝÁËÔõÑùʹÓà Docker ¾ÙÐÐÈÝÆ÷µÄÐÔÄܲâÊÔºÍѹÁ¦²âÊÔ £¬²¢ÌṩÁËÏêϸµÄ´úÂëʾÀý¡£Í¨¹ý¶ÔÈÝÆ÷µÄÐÔÄܺÍÎȹÌÐÔ¾ÙÐÐÆÀ¹À £¬¿ÉÒÔ×ÊÖúÎÒÃǸüºÃµØÏàʶÈÝÆ÷µÄÐÐΪºÍÐÔÄÜ £¬Ìá¸ßÓ¦ÓóÌÐòµÄÖÊÁ¿ºÍ¿É¿¿ÐÔ¡£ËäÈ» £¬ÕâÖ»ÊÇÒ»¸ö¼òÆÓµÄʾÀý £¬ÏÖʵµÄ²âÊÔÖпÉÄÜÐèÒª¸üÖØ´óµÄ²âÊԼƻ®ºÍ¹¤¾ß £¬Òò´ËÇëƾ֤ÏêϸÐèÇó¾ÙÐÐÏìÓ¦µÄµ÷½âºÍÓÅ»¯¡£

²Î¿¼ÎÄÏ×£º

Docker Documentation: https://docs.docker.com/

Apache Benchmark Documentation: http://httpd.apache.org/docs/2.4/programs/ab.html

JMeter Documentation: https://jmeter.apache.org/usermanual/index.html

ÒÔÉϾÍÊÇÔõÑùʹÓÃDocker¾ÙÐÐÈÝÆ÷µÄÐÔÄܲâÊÔºÍѹÁ¦²âÊÔµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ