Join the community today
Become a Member

Magento Nginx + Magento General info PDF

Discussion in 'Ecommerce / Shopping cart usage' started by eva2000, Jun 29, 2014.

  1. eva2000

    eva2000 Administrator Staff Member

    29,033
    6,589
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,782
    Local Time:
    3:19 PM
    Nginx 1.13.x
    MariaDB 5.5
    Not specifically about Centmin Mod Nginx configuration for Magento, but came across this PDF from Magento with alot of juicy info at http://info.magento.com/rs/magentocommerce/images/MagentoECG-PoweringMagentowithNgnixandPHP-FPM.pdf. Might be useful to some folks.

    Introduction
    Anyone looking for a simple Magento hosting solution should consider LAMP (Linux/Apache/ MySQL/PHP). However, there are cases when Apache with mod_php may not be an optimal solution, particularly if your web sites have dynamic content which is generated by PHP scripts in addition to static files. The purpose of this article is to explore the reasons behind this observation and to demonstrate how using Ngnix with PHP-FPM can help.

    Why You Should Consider Ngnix
    When dealing with many simultaneous HTTP/HTTPS connections, Apache uses a high amount of RAM and CPU cycles--especially when talking about a standard Apache configuration with the mod_php prefork. In general, each Apache child process consumes around 100MB of RAM on each request within a typical Magento installation. (To be clear, only resident memory is included in this statistic, minus shared RAM.) On average, a dedicated web server with 16GB of RAM can handle no more than roughly 150 concurrent requests.

    The major difference between Nginx and Apache is that Apache is process-based while nginx is event-based. Because Nginx is event-based it doesn’t need to spawn new processes or threads to increase its level of concurrency, so its memory footprint is very low. Nginx also exploits non-blocking, asynchronous I/O. Socket() and setsockopt() calls return results without blocking, whereas connect(), send(), recv() and close() may experience some blockage at times. Nginx calls the preceding functions only after confirming there will be no lag. To prevent blockage, for connect() as an example, the socket is changed in advance to a non-blocking socket using ioctl(). As for send() and recv(), epoll is used to prevent blockage. Codes for calling send() or recv() are composed in an event-driven format. Each event is composed of a socket, a socket state, and an operating function. Nginx is operated by a pre-set number of worker processes. Each process operates as a single isolated process. Ngnix’s non-blocking, event-driven architecture allows a single worker process to handle requests by multiple clients.

    As stated on the Nginx wiki:
    All of these factors allow Nginx to handle approximately 10,000 HTTP/HTTPS requests per second using just 10 to 20 MB RAM and utilizing about 10% to 15% of average CPU. (When dealing with HTTPS, CPU usage will be higher of course, because HTTPS decryption/encryption routines are highly CPU-intensive.)

    Ngnix and Static Content
    While the advantages of using Ngnix over Apache may be appealing, there is a specific drawback to using Ngnix in that it has nothing like mod_php to execute PHP applications directly its under control.

    Nginx is a static content web server and a reverse HTTP or FastCGI proxy. This means that it cannot run Magento directly, but must use another means to do so. Currently, the most beneficial method is to use PHP-FPM (also referred to as the FastCGI Process Manager (http://php-fpm.org/). PHP-FPM is specifically designed for running high-load web sites with PHP web applications. It consumes a fairly small amount of resident memory (about 30 MB for each child FPM process, roughly three times less than Apache mod_php would consume) and offers a number of unique features.

    These include:

    • Adaptive process spawning
    • Ability to start workers with different uid/gid/chroot/environment and different php.ini
    • Advanced logging including slowlog for slowly executing PHP scripts
    • Emergency restart in case of accidental opcode cache destruction
    • Real-time information on server activity and performance (includes real-time memory usage, CPU usage is more detailed, and you can output JSON, XML, HTML, or text). Provides more detail than Apache mod_status
     
  2. BoostN

    BoostN Member

    88
    18
    8
    Aug 19, 2014
    Ratings:
    +22
    Local Time:
    12:19 AM
    1.11.1
    10.0.28
    Has anyone used Centminmod for Magento that you know @eva2000 ?

    I have a few Magento sites running on Apache I'd love to try on the LEMP stack.
     
  3. eva2000

    eva2000 Administrator Staff Member

    29,033
    6,589
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,782
    Local Time:
    3:19 PM
    Nginx 1.13.x
    MariaDB 5.5
    I haven't personally used Magento, I think back on the old Centmin Mod Google+ Community there was someone, but not entirely sure.

    You're free to give it and go and report back or share your journey with us :D
     
  4. RoldanLT

    RoldanLT Well-Known Member

    3,830
    929
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,258
    Local Time:
    1:19 PM
    1.11
    10.2
    Maybe @Matt already try Magento.
     
  5. Matt

    Matt Moderator Staff Member

    680
    314
    63
    May 25, 2014
    Sheffield, UK
    Ratings:
    +433
    Local Time:
    6:19 AM
    1.7.1
    MariaDB 10
    Nope, it's the only one I've not used.
     
    • Like Like x 1
  6. BoostN

    BoostN Member

    88
    18
    8
    Aug 19, 2014
    Ratings:
    +22
    Local Time:
    12:19 AM
    1.11.1
    10.0.28
    • Like Like x 1
  7. eva2000

    eva2000 Administrator Staff Member

    29,033
    6,589
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,782
    Local Time:
    3:19 PM
    Nginx 1.13.x
    MariaDB 5.5