WordPress.org

Ready to get started?Download WordPress

Forums

Look-See Security Scanner
[resolved] Comparatively slow scan on one server (7 posts)

  1. ec5774
    Member
    Posted 5 months ago #

    Running the same version of WordPress, one on a Windows server and the other on a Linux server, the Windows server scans much faster than the Linux one - the Windows machine is able to scan 9,000 files in only a few sceonds whereas the Linux one takes minutes to complete a scan of only 3,500 files.

    I think the specs of the two machines are similar and one of the machines definitely has a faster hard drive, but would that make such a huge difference? Is it possible that there's a configuration problem on the Linux server?

    Thanks

    http://wordpress.org/plugins/look-see-security-scanner/

  2. blobfolio
    Member
    Plugin Author

    Posted 5 months ago #

    That's interesting, thank you for sharing!

    I assume your two set ups contain different user content (uploads and such)? A good way to quickly get a head-to-head comparison would be to do core-only scans on each system; that way it will scan the same files on each system.

    If the core-only scan performance is more or less the same for both, then the performance issue comes down to user content. Setting a reasonable upper file size limit should address this (try setting a limit of 1MB; most scripts will be much less than this). This way the scanner will not struggle generating a checksum on large images or video or whatever.

    If the core-only scans are still completing at very different rates, then there must be something unfortunate in the Linux set up. You might need to adjust the memory and cache settings in PHP, MySQL, and/or Apache (or NginX or whatever server software you're using). Benchmarking and monitoring software might help you locate areas of strength and weakness in the set up.

  3. ec5774
    Member
    Posted 5 months ago #

    Hi bobfolio,

    Thanks for your reply.

    The core scans are also much slower on the Linux system.

    I'll search around for php benchmarking information but it is very odd as page loads are actually faster on the Linux system than the Windows one - according to in-browser developer tools, the WP-Admin page is generated in 533ms on the Windows server and 169ms on the Linux server, so for general browsing the Linux server is unquestionably faster. That's why I was so surprised that the security scanner ran so slow on that system.

  4. blobfolio
    Member
    Plugin Author

    Posted 5 months ago #

    That is strange. I too have always found Linux to be much faster than Windows, except on really bad shared hosts (of which there are too many, haha).

    To help narrow it down further:
    When a scan is first started, there is a pre-scan of sorts, where the plugin crawls the directories and compiles a list of files to later scan. This pre-scan is completed once you first see the progress bar. Is this portion slow on the Linux server too, or does it complete in a comparable time (shouldn't be more than a second or two) to the Windows version?

    The scan itself is pretty simple:

    1. An AJAX query is submitted to WP.
    2. Look-See queries the database for up to 250 file paths to scan. This uses the WP database wrappers, and so shouldn't itself be a point of slowness if WP queries are normally speedy.
    3. For each file, it first checks to see if it exists (if not, the db is updated to note this);
    4. Assuming the file exists, it then checks the file size to see if it is larger than the allowed limit (if larger, the db is updated to note this).
    5. If the file exists and is within the allowed size range, it computes an MD5 checksum of the file and saves this value to the db.
    6. Once every file is checked, it returns a couple totals, and if there are more files to check, the process is repeated.

    From the above, there are three good candidates for slowness:

    A) Checking the file size has a performance penalty, but usually this is greatly outweighed by the savings of not MD5ing massive files.

    B) MD5 computations take a bit of time to perform. Less than stronger checksums, but more than something like CRC32. Overall it seemed the sanest choice of checksum algorithms.

    C) 250 separate update queries, though small in size (we aren't transmitting Moby Dick...), might still be more than MySQL wants to be bombarded with. A future version of the program will allow this value to be easily toggled, but if you wanted to quickly change it yourself, it is set at the top of the plugin's index.php file: define('LOOKSEE_SCAN_INTERVAL', 250); A smaller size will result in more AJAX queries to the server, but lighter loads per query.

    Thanks a bunch of helping me debug/improve the plugin!

  5. blobfolio
    Member
    Plugin Author

    Posted 5 months ago #

    I just pushed through an updated version, 13.11. If MySQL was the source of your bottleneck, this update should resolve it; the scan status updates are now grouped into a single query, resulting in 2x performance on my test machine. There is also now an option to skip cache files (which are kinda pointless to scan), which can further speed things up.

    I also updated the SSL analysis. Thanks for your suggestion on that.

  6. ec5774
    Member
    Posted 5 months ago #

    Hi bobfolio

    I've updated the plugin on my Linux machine and it's certainly faster, the scan completes in seconds rather than minutes. And now the Linux system beats the Windows system easily.

    (I also had to turn off WP_DEBUG in the mean time because I upgraded to PHP5.5 and was affected by http://core.trac.wordpress.org/ticket/21663#comment:117, but this shouldn't make any difference for these purposes)

    Thanks very much - both points seem to be fixed.

  7. blobfolio
    Member
    Plugin Author

    Posted 5 months ago #

    Yay! Thanks again for raising the issue and helping to improve this plugin!

Reply

You must log in to post.

About this Plugin

About this Topic