Sail Knowledgebase

Running the Sail Performance Profiler with cURL

You can use the cURL command line executable to invoke the Sail performance profiler. This combines the simplicity of Sail, with the power of cURL.

Simple URL profile

If you're looking to run the profiler on a simple GET request, you don't need to user cURL at all. Simply run:

sail profile https://example.org

You can learn more about profiling with Sail.

Profiling with cURL

Many performance problems will show up outside of simple GET requests. For example, you'll notice the increased page load time only for logged in users, or on POST requests with a specific payload, or other more complex scenarios.

For this reason, Sail ships with a wrapper function around the curl executable. This allows you to pass POST data, additional HTTP headers and more. Note that you will have to have curl already installed and configured on your system.

sail profile curl -X POST -d "param1=value1&param2=value2" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    https://example.org

This will perform a POST request, with the specified Content-Type header and POST data. Sail will additionally append its own profiling headers to make sure that profiling data is gathered and stored.

After the request is complete, the profile data will be downloaded from your production host to your local working copy, and opened in the Sail profile browser. For help navigating the profile browser read this.

Profiling with Chromium or another browser

You can invoke the Sail profiler from your browser. You'll just need to either specify the X-Sail-Profile header, or the SAIL_PROFILE request variable (in the query string, or POST data). The value of these should be set to the secret profile key of your Sail application. This can be obtained from:

sail profile key

After the request has finished, you will see an X-Sail-Profile entry in the HTTP response headers. It will contain the path to the saved profiling data, for example:

X-Sail-Profile: /var/www/profiles/xhprof.U41e60

This is the path to the profiling data on your production server. To download it to your local working copy, use:

sail profile download /var/www/profiles/xhprof.U41e60

The download command will place the profiling data file to your .profiles directory with the current date and time. You can the open the file with:

sail profile .profiles/filename.json

If you're looking for a Chrome/Chromium extension to modify request headers, try ModHeader.

Profiles consume disk space

When the performance profiler is invoked, it will store profiling data into the /var/www/profiles directory on the production server. When the Sail CLI downloads this data to a local working copy, it will delete the production profile file.

However, if you do not download these files, they will continue to exist on the production server, consuming valuable disk space.

This is especially important if you use the ModHeader or equivalent extensions, which unless disabled, will continue to gather profiling data on every request to your site made from your browser.

To remove any profiling files left behind, you can run:

sail ssh
rm -r /var/www/profiles/*

Locally-stored profiles will consume disk space too, you can delete them with:

cd /path/to/your/sail/project
rm -rf .profiles

If you're experiencing trouble or have any questions about profiling or WordPress performance in general, visit our getting help section.


Was this article helpful?

This helps us improve our knowledgebase.

Thanks!