Dmitri Tikhanski is a Contributing Writer to the BlazeMeter blog.

Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW!

arrow Please enter a URL with http(s)
Jan 03 2017

Load Testing FTP and SFTP Servers Using JMeter



Although Apache JMeter is mainly used for testing web applications over HTTP and HTTPS protocols, it is still a modular multiprotocol load testing tool. This means that its load testing capabilities are not limited only to web applications testing. Attentive readers of this blog are aware of at least the following supported protocols:


- JDBC - from The Real Secret to Building a Database Test Plan With JMeter and Using JDBC Sampler In JMeter articles

- SMTP, IMAP and POP3 - from Load Testing Your Email Server: How to Send and Receive E-mails with JMeter article

- JMS - from Building a JMS Testing Plan - Apache JMeter article


In this article I will cover a few more protocols. When you finish reading, you will know how to build FTP, FTPS and SFTP test plans using JMeter.


First of all, a little bit of history: FTP is the acronym for File Transfer Protocol. The protocol itself was drafted in 1971 - more than 45 years ago. The first evidences of FTP protocol usage for transferring files over ARPANET date back to 1973. You have most likely you used it directly or indirectly, yourself. FTP client programs are default parts of Windows and MacOSX operating systems and the majority of Linux and Unix-derivatives distributions; File Transfer Protocol is supported by the majority of web browsers, for example Wix or SquareSpace website building  platforms use FTP for transferring content; FTP is one of the primary ways of publishing websites developed via Microsoft Visual Studio, etc.


Therefore, load testing of FTP servers is important for determining their capacity, measuring throughput, checking the impact of severe load for a prolonged time and so on. 




The FTP Request sampler GUI looks like this:


ftp request sampler gui




- Server Name or IP: the FTP server endpoint, basically the FTP server IP address or hostname (in some cases it may be a load balancer)

- Port Number: the port FTP server listens for incoming connections. The default FTP port 21 will be used unless a different configuration is provided

- Remote File: the path to the file on the FTP server, which will be downloaded or used as a destination path for a file upload

- Local File: the path to the file on the local file system (where JMeter is running), which will be uploaded to the FTP server or to where the remote file is stored locally

- Local File Contents: in case of a file upload request, the source file content can be provided via this input field (can be used instead of the “Local File”, overrides “Local File” input)

- get(RETR) - indicates the file will be downloaded from the FTP server

- put(STOR) - indicates the file will be uploaded to the FTP server

- Use Binary mode - whether to use “binary” mode for file transfers. If you are uploading/downloading plain text files - uncheck this box, in all other cases keep this checked

- Save File in Response: if this box is checked (in case of “get(RETR)” requests) retrieved file content will be stored as the FTP Request sampler Response Data (so it can be visualized and used in PostProcessors and Assertions)

- Login Configuration: if the FTP server requires credentials they can be provided via this control


Upload a File


To test the file upload all you need is:


- to provide either the file path on a local file system or the file content - the file will be created by JMeter on the fly (JMeter Functions and Variables can be used)

- the path to the remote file (if the file doesn’t exist - it will be created, if it exists - it will be overwritten)


- Select put(STOR) radiobutton


ftp request upload


Download a File


Now, let’s download the previously uploaded file by applying the next configuration to the FTP Request Sampler:


- Server Name, Port Number and Remote File remain the same

- Local File and Local File Contents should be blank

- Select get(RETR) radiobutton

- Tick Save File in Response as we are going to view the content of the previously uploaded file in the View Results Tree Listener


ftp request download


Assuming everything goes well you should see “foo.txt” file content in the View Results Tree Listener.


ftp request, view results tree listener


As you can see, the content of the downloaded file matches the content we uploaded in the previous step, __time() function has been substituted with the timestamp in the defined format.


Advanced Scenarios


At this point you should be able to upload and download files, which are the most popular FTP server use cases. However, there might be some scenarios that are currently not supported by JMeter but you may need to load test them as well.


Here are a few examples of common FTP tasks which cannot be implemented using FTP Request sampler. All the examples assume JSR223 Sampler and Groovy language.


JMeter FTP connectivity is powered by Apache Commons Net library so you will mostly need FTPClient class for file and folder operations.


Listing folder contents


You can get list of files in FTP folder via the FTPClient.listFiles() function. Be aware that by default hidden files will not be listed.



def ftpClient = new FTPClient()
ftpClient.connect("", 21)
ftpClient.login("blazemeter", "secret")
ftpClient.listFiles().each {


ftp request listing folder contents


The above example is just printing files to the jmeter.log file which is pretty useless, so you may want to store the file names into JMeter Variables for later use.


Renaming a File


In order to rename a file (or folder), it’s enough to call the FTPClient.rename() function and provide the source and destination file (or folder) names:



def ftpClient = new FTPClient()
ftpClient.connect("", 21)
ftpClient.login("blazemeter", "secret")

def success = ftpClient.rename("foo.txt", "bar.txt")"File rename success: " + success)


ftp request renaming a file


Deleting a File


Deleting a file is simple: call the FTPClient.deleteFile() function and provide the path to the file you want to delete as an argument.



def ftpClient = new FTPClient()
ftpClient.connect("", 21)
ftpClient.login("blazemeter", "secret")

def success = ftpClient.deleteFile("bar.txt")"File rename success: " + success)


ftp request deleting a file


To delete a folder you need to use call FTPClient.removeDirectory() function and provide the path to the folder as a parameter. Remember that the folder needs to be empty, otherwise it will not be removed. If there are files under the folder - you will need to delete them first.




We can safely assume that since the FTP protocol specification was developed a very long time ago, the serving file transfers in a closed organisation with a limited number of users and computers it is not designed securely. This means that credentials are being sent in plain text and packets are not encrypted, so basically anyone with a sniffer tool like Wireshark can capture the traffic and steal the data.


For this reason, FTP support of Secure Sockets Layer providing data encryption was drafted in 1996 followed, by implementation of the extra security features. Basically, FTPS acts like HTTPS and the encryption is applied on the transport layer.


As of version 3.1 JMeter does not support FTPS via FTP Request sampler GUI. You will need to use Groovy scripting in order to establish connection and upload/download/list/delete files and/or folders. Check to get sample code for establishing secure FTP connection.  




Despite the letters “FTP” in its name, SFTP has nothing in common with FTP and FTPS. SFTP uses secure shell, aka SSH protocol, for authentication and commands, and SFTP for file transfer.


JMeter 3.1 doesn’t support SSH connectivity out-of-the-box, however it may be added via the following samplers:


- SSH Command - for executing commands

- SSH SFTP - for transferring files back and forth


Both samplers are available via the JMeter Plugins project, the fastest and the easiest way of installing plugins along with dependencies (if required) and keeping them up-to-date is using JMeter Plugins Manager.


sftp, jmeter plugins manager, ssh


Once installation is finished and JMeter is restarted you should see the new SSH SFTP sampler which enables performing SFTP file operations.


ssh sftp sampler, jmeter


At this point you should know everything required for load testing FTP and/or SFTP servers using JMeter. As usual you are welcome to use the below discussion form for any queries, if anything is still unclear or if your use case is not covered.

arrow Please enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!