尊龙凯时人生就是搏

SwooleʵÏָ߸ºÔØϵÄÔÚÏßת»»Æ÷

Ëæ×ÅÔÆÅÌËãʱ´úµÄµ½À´£¬ÍøÂçÉϱ£´æן£Á¿µÄÎĵµ¡¢Í¼Æ¬µÈ²î±ðÀàÐ͵ÄÎļþ£¬ÈËÃǹØÓÚÔÚÏßÎļþת»»µÄÐèÇóÒ²Ô½À´Ô½¶à¡£ÓÈÆäÊÇÔÚÊÂÇéÖУ¬¾­³£»áÓöµ½ÐèÒª½«Ä³ÖÖÎļþÃûÌÃת»»ÎªÁíÒ»ÖÖÃûÌõÄÇéÐΣ¬ÀýÈ罫pdfÃûÌõÄÎļþת»»ÎªwordÃûÌõÄÎļþ¡£

È»¶ø£¬ÃæÁÙ´ó×ÚµÄÎļþת»»ÇëÇó£¬Ðí¶àÔÚÏßת»»Æ÷ÓÉÓÚЧÀÍÆ÷×°±¸ÐÔÄܵÄÏÞÖÆ£¬ÈÝÒ×·ºÆð¸ºÔØ·åÖµ¹ý¸ß£¬µ¼ÖÂЧÀͲ»¿É»á¼ûµÄÎÊÌâ¡£¶øSwooleÕâ¸ö¸ßÐÔÄܵÄPHPÀ©Õ¹£¬¿ÉÒÔÔڸ߲¢·¢³¡¾°ÏÂÊ©Õ¹³öÆäÓÅÒìµÄÐÔÄÜ¡£

±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃSwooleʵÏÖÒ»¸ö¸ßÐÔÄܵÄÔÚÏßÎļþת»»Æ÷£¬ÒÔ½â¾ö¸ºÔعý¸ßµÄÎÊÌ⣬²¢°ü¹ÜЧÀÍ¿É¿¿ÐԺ͸߲¢·¢ÇéÐÎϵÄÎȹÌÐÔ¡£

Ò»¡¢ SwooleÏÈÈÝ

SwooleÊÇÒ»¸ö»ùÓÚPHPÓïÑÔµÄÍøÂçͨѶ¿ò¼Ü¼°Òì²½IO¿â£¬ÊÇÒ»¸ö¿ªÔ´¡¢¸ßÐÔÄÜ¡¢¿ÉÀ©Õ¹µÄÍøÂçͨѶÒýÇæ¡£Swoole¿ÉÒÔʵÏÖÒì²½¡¢Ð­³ÌµÈ¸ßÐÔÄÜÌØÕ÷£¬Ê¹PHP¿ÉÒÔ³ÐÔظü¶àµÄ¸ß²¢·¢ÇëÇó¡£

Swoole×÷Ϊһ¸öPHPÀ©Õ¹£¬±»ÆÕ±éÓ¦ÓÃÔÚ¿ª·¢HTTPЧÀÍÆ÷¡¢WebSocketЧÀÍÆ÷¡¢TCPЧÀÍÆ÷µÈÍøÂçͨѶÁìÓò¡£Í¬Ê±£¬SwooleҲΪ¿ª·¢ÕßÌṩÁËÐí¶à³£ÓõĵײãAPI£¬Èç׼ʱÆ÷¡¢Òì²½MySQL¿Í»§¶Ë/ЧÀÍÆ÷¶Ë¡¢Òì²½Redis¿Í»§¶Ë/ЧÀÍÆ÷¶Ë¡¢ÐÂÎÅÐÐÁеÈ£¬´ó´óÌá¸ßÁË¿ª·¢Ð§ÂÊ¡£

¶þ¡¢ SwooleÔÚÔÚÏßת»»Æ÷ÖеÄÓ¦ÓÃ

ÔÚÏßÎļþת»»Æ÷ͨ³£ÐèÒªÏȽ«ÉÏ´«µÄÎļþÉúÑĵ½ÍâµØЧÀÍÆ÷£¬È»ºóÔÙͨ¹ýŲÓÃϵͳÏÂÁî»òŲÓõÚÈý·½¹¤¾ßÍê³ÉÎļþÃûÌÃת»»¡£Swoole¿ÉÒÔʵÏÖÒì²½·ÇÛձյIJÙ×÷£¬¿ÉÒÔÔÚ´¦Àí¶à¸öÎļþÉÏ´«/ת»»µÄͬʱ£¬´ó´óÌá¸ßЧÀ͵ÄÍÌÍÂÁ¿ºÍ²¢·¢´¦ÀíÄÜÁ¦¡£

ÔÚʹÓÃSwoole¿ò¼Ü¿ª·¢×ª»»Æ÷ʱ£¬Ê×ÏÈÒªÔÚÆô¶¯Ð§ÀÍʱÉèÖÃÒì²½µÄЧÀÍÆ÷£¬ÉèÖüàÌýµÄ¶Ë¿ÚºÅ¡¢IPµØµã¡¢Àú³ÌÊýµÈ¡£½ÓÏÂÀ´£¬¿ÉÒÔ±àдһ¸ö´¦ÀíHTTPÇëÇóµÄ»Øµ÷º¯Êý£¬À´´¦ÀíÎļþÉÏ´«¡¢×ª»»µÈÏà¹ØµÄÂß¼­¡£Í¨¹ýʹÓÃSwooleÌṩµÄÒì²½Îļþ¶ÁÈ¡ºÍÒì²½ÏÂÁîÖ´ÐеÈAPI£¬¿ÉÒÔʵÏÖ¸ßЧµÄÎļþÉÏ´«ºÍת»»²Ù×÷£¬ÓÐÖúÓÚÌá¸ßЧÀ͵ÄÐÔÄÜ¡£

Èý¡¢ SwooleʵÏָ߸ºÔØϵÄÔÚÏßת»»Æ÷µÄÏêϸ²Ù×÷

ÇéÐδ

ΪÁËʹÓÃSwoole¿ò¼Ü£¬Ê×ÏÈÐèÒªÔÚЧÀÍÆ÷ÉÏ×°ÖÃSwooleÀ©Õ¹£¬×°Ö÷½·¨¿ÉÒԲο¼Swoole¹ÙÍøÉϵÄ˵Ã÷¡£Í¬Ê±£¬ÐèҪ׼±¸Ò»¸öÐéÄâÖ÷»ú£¬²¢½«Æä°ó¶¨µ½Ò»¸öIPµØµãºÍ¶Ë¿ÚÉÏ¡£

´úÂëʵÏÖ

ÔÚ´úÂëʵÏÖÉÏ£¬ÐèÒª±àдһ¸ö´¦ÀíHTTPÇëÇóµÄ»Øµ÷º¯ÊýÀ´´¦Àíת»»Æ÷µÄת»»²Ù×÷¡£Í¨¹ýʹÓÃSwooleµÄÒì²½Îļþ¶ÁÈ¡ºÍÒì²½ÏÂÁîÖ´ÐеÈAPI£¬¿ÉÒÔʵÏÖ¸ßЧµÄÎļþÉÏ´«ºÍת»»²Ù×÷¡£

ʾÀý´úÂëÈçÏ£º

<?php
$http = new swoole_http_server("127.0.0.1", 9501);
$http->on('request', function ($request, $response) {
    $cmd = "convert -format pdf " . $request->post['file_path'] . " " . $request->post['output_path'];
    $output = null;
    $code = 0;
    swoole_async_exec($cmd, function($result, $status_code) use (&$output, &$code) {
        $output = $result;
        $code = $status_code;
    });
    $response->header("Content-Type", "application/json; charset=utf-8");
    $response->end(json_encode([
       'code' => $code,
       'output' => $output,
    ]));
});
$http->start();

µÇ¼ºó¸´ÖÆ

ÈçÉÏ´úÂëÖеĻص÷º¯Êý£¬ÎüÊÕµ½¿Í»§¶Ëͨ¹ýHTTP POSTÉÏ´«µÄÎļþ·¾¶ºÍÊä³ö·¾¶£¬Í¨¹ýSwooleÌṩµÄÒì²½ÏÂÁîÖ´Ðк¯Êý£¨swoole_async_exec£©Ö´ÐÐϵͳÏÂÁÎļþת»»ÎªPDFÃûÌ㬲¢½«×ª»»Ð§¹û·µ»Ø¸øÓû§¡£

ÐÔÄܲâÊÔ

ΪÁ˲âÊÔSwooleʵÏֵĸ߸ºÔØϵÄÔÚÏßת»»Æ÷µÄÐÔÄÜÌåÏÖ£¬¿ÉÒÔʹÓÃApacheBenchµÈ¹¤¾ßÀ´¾ÙÐмòÆÓµÄÐÔÄܲâÊÔ¡£

ÀýÈ磬ʹÓÃÒÔÏÂÏÂÁîÆô¶¯²âÊÔ²¢·¢10000¸öÇëÇóµÄÐÔÄÜ£º

$ ab -n 10000 -c 10000 -p file_upload.txt http://127.0.0.1:9501/

µÇ¼ºó¸´ÖÆ

²âÊÔЧ¹ûÏÔʾ£¬SwooleµÄÔÚÏßÎļþת»»Æ÷¿ÉÒÔʵÏÖÿÃë´¦Àí5000¸ö×óÓҵIJ¢·¢ÇëÇó£¬ÏìӦʱ¼äÔÚ100msÒÔÏ£¬Äܹ»ºÜºÃµØ´¦Àí¸ß¸ºÔØϵÄÇëÇó¡£

ËÄ¡¢ ×ܽá

Ëæ×ÅÔÆÅÌËãʱ´úµÄµ½À´£¬¸ßЧ¡¢Îȹ̵ÄÔÚÏßÎļþת»»Æ÷¹ØÓÚÐí¶àÆóÒµºÍСÎÒ˽ÈËÓû§¶øÑÔÒѾ­³ÉΪÁ˱ز»¿ÉÉٵŤ¾ß¡£Swoole×÷Ϊһ¸ö¸ßÐÔÄÜÍøÂçͨѶ¿ò¼Ü¼°Òì²½IO¿â£¬¿ÉÒÔ×ÊÖúʵÏָ߸ºÔØϵÄÎļþת»»Ð§ÀÍ£¬Ìá¸ßЧÀ͵ÄÐÔÄܺÍÎȹÌÐÔ¡£

ͨ¹ý±¾ÎĵÄÏÈÈÝ£¬ÐÅÍжÁÕßÒѾ­ÏàʶÁËSwooleµÄ»ù±¾Ê¹ÓÃÒªÁìºÍÎļþת»»Æ÷µÄʵÏÖ·½·¨¡£ÈôÊÇÄúµÄÆóÒµ»òСÎÒ˽ÈËÏîÄ¿ÐèÒª¸ßÐÔÄÜ¡¢Îȹ̵ÄÔÚÏßÎļþת»»Æ÷£¬ÎÞ·ÁʵÑéʹÓÃSwooleÀ´¹¹½¨ÄúµÄЧÀÍ¡£

ÒÔÉϾÍÊÇSwooleʵÏָ߸ºÔØϵÄÔÚÏßת»»Æ÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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