# READ_ME: CSVファイルの読み込みパフォーマンステスト ###### tags: `MuleSoftTraining` 必要なファイル: performanceTestingResults_JP.xlsx 手順1: `perfomance` 以下に4つのフォルダを構成します。 - input - output - archive - sampleData ![](https://i.imgur.com/8mTICfd.png) 手順2: mod14-perfomance-playground.jar を Anypoint Studio に Import します。 手順3: fileStreaming.xml の Global Elements タブ > File コネクタ設定より、ワーキングディレクトリを`performance`フォルダに設定します。 ![](https://i.imgur.com/upxCUml.jpg) 手順4: 右クリック > Run Project よりプロジェクトを実行します。 手順5: 下記のHTTPリクエストを行い、sampleDataディレクトリ内に2つのcsvファイルを作成します。 `GET: http://localhost:8081/fileStreaming/createFile?numOfRows=5000000`(134MB) `GET: http://localhost:8081/fileStreaming/createFile?numOfRows=40000000`(1.1GB) ![5](https://i.imgur.com/cYjYfba.png) 手順6: テストしたいファイルを「input」フォルダに置くと、MuleアプリケーションのOn New or Updated File リスナーがファイルを読み取ります。 ![6](https://i.imgur.com/5XSCW7G.png) 手順7: 処理後のファイルはarchiveに移動されます。 ![7](https://i.imgur.com/JFzOG8P.png) 手順8: ログに処理時間が記録されます。(単位は秒(S)) ![8](https://i.imgur.com/NezU2Nd.png) 以下、performanceTestingResults_JP.xlsx の各列に記載されている、変更可能なパラメータについて記載します。 ### 列C File コネクタ - On New or Updated File リスナー: streaming strategy (ストリーミング戦略) https://docs.mulesoft.com/jp/file-connector/1.3/file-documentation#listener - repeatable file store stream (デフォルト) - non repeatable stream - repeatable in memory stream ![C](https://i.imgur.com/A2FCdhz.png) ### 列D: File コネクタ - On New or Updated File リスナー:MIME type streaming setting(MIME タイプのストリーミング戦略) https://docs.mulesoft.com/dataweave/2.4/dataweave- streaming#enabling-streaming > To enable streaming when reading source data, you must set the streaming reader property to true on the data source. You can enable streaming on a data source through the MIME Type setting outputMimeType. You can set the property in a Mule component that accepts source data, such as an HTTP listener or an On New or Updated File operation. ``` <flow name="dw-streaming-example" > <http:listener doc:name="Listener" outputMimeType="application/json; streaming=true" config-ref="HTTP_Listener_config" path="/input"/> </flow> ``` > streaming=true > Notice that streaming=true is part of the outputMimeType value. Other Mule components, such as the File and FTP components, also support the MIME Type setting. - false デフォルト `key - streaming` : `value - false` - true `key - streaming` : `value - true` ![D](https://i.imgur.com/xkWows3.png) ### 列E: DataWeave: transformation settings (変換の設定) - `bufferSize=819200` - デフォルト 8192 - `indent=false` - JSON のインデントを無くした方がパフォーマンスが良い? - `deffered=true` - After processing streamed data, you can stream the output directly to another message processor. - 次のプロセッサに渡るまで、ストリームのデータの変換ロジックの実行を遅延(deffered)させる。= ストリームのデータ自体をそのまま直接(directly)次のプロセッサに渡す = パフォーマンスが上がる? - https://docs.mulesoft.com/dataweave/2.4/dataweave-streaming#stream_output - When in deferred mode, DataWeave can also pass streamed output data directly to a message processor without saving it to the disk. This behavior enables DataWeave and Mule to process data faster and consume fewer resources than the default processes for reading and writing data. - https://docs.mulesoft.com/dataweave/2.4/dataweave-streaming ![E](https://i.imgur.com/P4zd0Pv.png) ### 列F: Transform to java as well? (Java に変換する?) Transform Message を使用して、Java への変換をパフォーマンスへの影響をテスト(CSV->Java->JSON) ### 列G: logging payload? (payload をログ出力する?) Loggerコンポーネントを使用して、payloadを出力する/しないことの変化を測定 ### その他資料 https://docs.mulesoft.com/dataweave/2.4/dataweave-memory-management https://docs.mulesoft.com/jp/mule-runtime/4.4/intro-transformations https://docs.mulesoft.com/dataweave/2.4/dataweave-streaming