Endy's avatar
Level 1

100CPU usage AFTER file uploaded with Octane

What's the problem:

I'm using laravel/framework 9.19 + octane 1.3 + swoole 4.8.2 for my application. When I upload a large file, two PHP processes increase the CPU usage to 100%, and it won't decrease after the file upload is completely finished, unless I restart the octane service. I used chunked upload and merge in the process above, the total size of those files are almost between 5m and 10m.

What I've done for it:

  • barryvdh answered a farmiliar question long time ago, that's because octane writes every thing using debug level SWOOLE_LOG_INFO under local env. I change that to SWOOLE_LOG_ERROR in config/octane.php and there's no more increase to swoole_http.log, but the CPU usage still up to 100%.
0 likes
6 replies
Tray2's avatar

What kind of file are you uploading and what are you doing with it?

Endy's avatar
Level 1

@Tray2 Just images, chunked upload->merge->save to storage->return url. Didn't use them yet.

Tray2's avatar

@Endy So resizings or manipulations?

Then why do you need Octane, isn't that a bit of overkill?

martinbean's avatar

@endy Octane doesn’t “clean up” after requests because it uses a single long-running process to handle HTTP requests. So it sounds like you’re not clearing up resources after performing operations.

As mentioned, Octane isn’t suitable for trying to magically make intensive tasks like image manipulation faster. Use a queue worker to do that work asynchronously. Each job will be performed in its own process and therefore any resources free once the job has completed.

Endy's avatar
Level 1

@martinbean I want to speed up my application, but the api for uploading files is also forwarded by route. How can I set this route to use fpm separately, and other routes to use octane?

Endy's avatar
Level 1

Thank you for your answers.

Please or to participate in this conversation.