= Test Write Performance
:toc:
:icons:
:linkattrs:
:imagesdir: ../resources/images


== Summary

This section will test the write performance of the local FSx File Gateway in Region 2, the same region as this Windows instance, and compare it to the write performance of the remote FSx for Windows File Server in Region 1.

There are many disk performance tools out there. link:https://aka.ms/diskspd[DiskSpd] have been pre-installed on the *WindowsInstance*.

== Duration

NOTE: It will take approximately 15 minutes to complete this section.


== Step-by-step Guide

IMPORTANT: Read through all steps below and watch the quick video before *_clicking_* the *Deploy to AWS* button.

image::create-update-delete.gif[title="Quick Step-by-step Video", align="left", width=600]

=== Compare file creations between the local FSx File Gateway and the remote FSx for Windows File Server

. Arrange the two *File Explorer* windows so you can see both contents at the same time.

. From the *File Explorer* window with the mapped *Z:* drive pointing to the remote FSx for Windows File Server, *_context-click_* (*_right-click_*) and select *New >> TextDocument* and give it a new name (e.g. Test1).
. Do you see the file in both *File Explorer* windows?
. Refresh the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway.
. Wait a minute and try again. Continue *_refreshing_* the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway.
+
NOTE: Changes made to the underlying FSx for Windows File Server are periodically pushed to the attached FSx File Gateways.
+
. From the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway, *_context-click_* (*_right-click_*) and select *New >> TextDocument* and give it a new name (e.g. Test2).
. Do you see the file in both *File Explorer* windows?
+
NOTE: Changes made to the FSx File Gateway are immediately pushed to the attached FSx for Windows File Server.

=== Compare file updates between the local FSx File Gateway and the remote FSx for Windows File Server

. Arrange the two *File Explorer* windows so you can see both contents at the same time.

. From the *File Explorer* window with the mapped *Z:* drive pointing to the remote FSx for Windows File Server, *_open_* the *Test1* file you created earlier and update its content (e.g. add your first name to the file).
. *_Save_* and *_close_* the file.
. From the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway, *_open_* the *Test1* file you updated earlier.
. Do you see the changes you made in the version of the file from the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway?
. Wait a minute and try again. Continue opening the *Test1* file until you see the changes you made to the file from the *File Explorer* window with the mapped *Z:* drive pointing to the remote FSx for Windows File Server reflected in the the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway.
+
NOTE: Changes made to the underlying FSx for Windows File Server are periodically pushed to the attached FSx File Gateways.
+
. From the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway, *_open_* the *Test2* file you created earlier and update its content (e.g. add your last name to the file).
. *_Save_* and *_close_* the file.
. From the *File Explorer* window with the mapped *Z:* drive pointing to the remote FSx for Windows File Server, *_open_* the *Test2* file you updated earlier.
. Do you see the changes you made to the file when accessed from the *File Explorer* window with the mapped *Z:* drive pointing to the remote FSx for Windows File Server?
+
NOTE: Changes made to the FSx File Gateway are immediately pushed to the attached FSx for Windows File Server.


=== Compare file deletes between the local FSx File Gateway and the remote FSx for Windows File Server

. Arrange the two *File Explorer* windows so you can see both contents at the same time.

. From the *File Explorer* window with the mapped *Z:* drive pointing to the remote FSx for Windows File Server, *_delete_* the *Test1* file you created earlier.
. Do you see *Test1* in the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway?
. Wait a minute and try again. Continue *_refreshing_* the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway.
+
NOTE: Changes made to the underlying FSx for Windows File Server are periodically pushed to the attached FSx File Gateways.
+
. From the *File Explorer* window with the mapped *Y:* drive pointing to the local FSx File Gateway, *_delete_* the *Test2* file you created earlier.
. Do you see *Test2* from the *File Explorer* window with the mapped *Z:* drive pointing to the remote FSx for Windows File Server?
. Refresh the *File Explorer* window with the mapped *Z:* drive pointing to the remote FSx for Windows File Server.
. Do you see *Test2* from the *File Explorer* window with the mapped *Z:* drive pointing to the remote FSx for Windows File Server?
+
NOTE: Changes made to the FSx File Gateway are immediately pushed to the attached FSx for Windows File Server.

=== DiskSpd Write tests

IMPORTANT: Read through all steps below and watch the quick video before *_clicking_* the *Deploy to AWS* button.

image::write-test.gif[title="Quick Step-by-step Video", align="left", width=600]

==== Test write performance accessing the remote FSx for Windows File Server.

. From the remote desktop session to the *Windows Instance*, *_click_* *Start* >> *Windows PowerShell*.

+
IMPORTANT: This section assumes the remote FSx for Windows File Server is mapped as the *Z:* drive.
+
. *_Run_* the script below in the PowerShell session to create a 1 GB sparse file.
+
```sh
fsutil file createnew Z:\${env:computername}-fsxw.dat 1000000000
```
+
. Run the DiskSpeed script below in the PowerShell session to test write performance of the remote FSx for Windows File Server mapped as the **Z:** drive.
+
```sh
C:\Tools\DiskSpd\amd64\DiskSpd.exe -d120 -w100 -r -t1 -o32 -b1M -Sr -L Z:\${env:computername}-fsxw.dat
```
+
While the script is running, open *Task Manager* and monitor network performance (e.g. Start >> Task Manager >> More details >> Performance (tab) >> Ethernet). The DiskSpd script will complete in 120 seconds. After the script has completed, the output will be displayed in the PowerShell window.
+
* What was the P99 (99th %-tile) latency in ms of your test? - This is found in the DiskSpd output. It is in the *total* table at the bottom.
* What was the P99.99 (99.99th %-tile) latency in ms of your test? - This is found in the DiskSpd output. It is in the *total* table at the bottom.
* What was the Total Write IO MiB/s? - This is found in the DiskSpd output. It is under *Write IO* under the *MiB/s* column.
* What was the I/O per second? - This is found in the DiskSpd output. It is under *Write IO* under the *I/O per s* column.
* What was the AvgLat? - This is found in the DiskSpd output. It is under *Write IO* under the *AvgLat* column.
+
. Copy the following table to your local computer and records the results
+
[width="50%",cols="d,d,d",frame="topbot",options="header"]
|===
h| EC2 Instance (us-west-1) | FSx for Windows File Server (us-east-1) | FSx File Gateway (us-west-1)
s| DiskSpd Write (metric) h| Write h| Write
| Read IO throughput (MiB/s)
|
|

| Read IO I/O per s
|
|

| Read IO AvgLat (ms)
|
|

| Min %-tile (ms)
|
|

| 50th %-tile (ms)
|
|

| 90th %-tile (ms)
|
|

| 99th %-tile (ms)
|
|

| 99.99th %-tile (ms)
|
|
|===
+
. Experiment with different DiskSpd parameter settings. Use the table below as a guide. Test with different block sizes (-b), number of outstanding I/O requests (-o), number of threads per file (-t), and disable local caching (-Sr).
+
[cols="3,10"]
|===
| Parameter | Description

| `-b<size>[K\|M\|G]`
a| Block size in bytes or KiB, MiB, or GiB (default = 64K).

| `-o<count>`
a| Number of outstanding I/O requests per-target per-thread. (1 = synchronous I/O, unless more than one thread is specified with by using `-F`.) (default = 2)

| `-r<size>[K\|M\|G]`
a| Random I/O aligned to the specified number of <alignment> bytes or KiB, MiB, GiB, or blocks. Overrides -s (default stride = block size).

| `-s<size>[K\|M\|G]`
a| Sequential stride size, offset between subsequent I/O operations in bytes or KiB, MiB, GiB, or blocks. Ignored if -r is specified (default access = sequential, default stride = block size).

| `-t<count>`
a| Number of threads per target. Conflicts with `-F`, which specifies the total number of threads.

| `-Sr`
a| Disable local caching.

|===

* What different parameters did you test?
* How did the different parameter options alter the results?


==== Test write performance accessing the local FSx File Gateway.

IMPORTANT: This section assumes the local FSx File Gateway is mapped as the *Y:* drive.

. *_Run_* the script below in the PowerShell session to create a 1 GB sparse file.
+
```sh
fsutil file createnew Y:\${env:computername}-fsxgw.dat 1000000000
```
+
. Run the DiskSpeed script below in the PowerShell session to test write performance of the remote FSx File Gateway mapped as the *Y:* drive.
+
```sh
C:\Tools\DiskSpd\amd64\DiskSpd.exe -d120 -w100 -r -t1 -o32 -b1M -Sr -L Y:\${env:computername}-fsxgw.dat
```
+
While the script is running, open *Task Manager* and monitor network performance (e.g. Start >> Task Manager >> More details >> Performance (tab) >> Ethernet). The DiskSpd script will complete in 120 seconds. After the script has completed, the output will be displayed in the PowerShell window.
+
* What was the P99 (99th %-tile) latency in ms of your test? - This is found in the DiskSpd output. It is in the *total* table at the bottom.
* What was the P99.99 (99.99th %-tile) latency in ms of your test? - This is found in the DiskSpd output. It is in the *total* table at the bottom.
* What was the Total Write IO MiB/s? - This is found in the DiskSpd output. It is under *Write IO* under the *MiB/s* column.
* What was the I/O per second? - This is found in the DiskSpd output. It is under *Write IO* under the *I/O per s* column.
* What was the AvgLat? - This is found in the DiskSpd output. It is under *Write IO* under the *AvgLat* column.
+
. Record the results in the table you copied to your local computer earlier.
+
. Experiment with different DiskSpd parameter settings. Use the table below as a guide. Test with different block sizes (-b), number of outstanding I/O requests (-o), number of threads per file (-t), and disable local caching (-Sr).
+
[cols="3,10"]
|===
| Parameter | Description

| `-b<size>[K\|M\|G]`
a| Block size in bytes or KiB, MiB, or GiB (default = 64K).

| `-o<count>`
a| Number of outstanding I/O requests per-target per-thread. (1 = synchronous I/O, unless more than one thread is specified with by using `-F`.) (default = 2)

| `-r<size>[K\|M\|G]`
a| Random I/O aligned to the specified number of <alignment> bytes or KiB, MiB, GiB, or blocks. Overrides -s (default stride = block size).

| `-s<size>[K\|M\|G]`
a| Sequential stride size, offset between subsequent I/O operations in bytes or KiB, MiB, GiB, or blocks. Ignored if -r is specified (default access = sequential, default stride = block size).

| `-t<count>`
a| Number of threads per target. Conflicts with `-F`, which specifies the total number of threads.

| `-Sr`
a| Disable local caching.

|===

* What different parameters did you test?
* How did the different parameter options alter the results?


=== DiskSpd Write Results

The following table and charts show the results from a previous test. These results show a significant improvement when an Amazon EC2 Windows instance (us-west-1) writes to a large file on the local FSx File Gateway (us-west-1) compared to a remote FSx for Windows File Server (us-east-1).

* Compare your test results with those in following. Do they differ substantially? Why?


image::write-results-table-a.png[title="DiskSpd Write Results Table - sample", align="left", width=1000]
---
image::write-results-throughput-chart-a.png[title="DiskSpd Write Throughput Chart - sample", align="left", width=800]
---
image::write-results-latencies-chart-a.png[title="DiskSpd Write Latencies Chart - sample", align="left", width=800]
---

* Using different hardware resources to host the FSx File Gateway will affect performance (e.g. allocating more CPUs, network bandwidth, larger/faster disks, more memory, etc.).

== Next section

Click the button below to go to the next section.

image::test-read-performance.png[link=../08-test-read-performance/, align="left",width=420]





