swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.03k stars 388 forks source link

Change to swoole_base #513

Closed juber-nunes closed 2 years ago

juber-nunes commented 2 years ago

This is more a question as opposed to a bug.

How can I switch between SWOOLE_PROCESS to SWOOLE_BASE?

https://wiki.swoole.com/#/learn?id=swoole_base

Thanks in advance

Arkanius commented 2 years ago

Hi there!

This is designed to use with SWOOLE_PROCESS

I think that with hyperf you can have this kind of customization, but I'm not sure.

Anyway, be careful with SWOOLE_BASE, with this option you won't be able to use some stuffs like "max_request", "dispatch_mode", etc

See you

juber-nunes commented 2 years ago

Thanks @Arkanius

The reason behind the question is the fact I'm facing some issues with all the goodies from SWOOLE_PROCESS. For an (yet) unexplained reason the workers are getting stuck without CPU or memory consumption but unable to process any incoming requests. As soon as it restarted all works well for a certain period of time. I believe is something related to a long query or something around that, as I drop those connection from DB the instances running the application all becomes healthy again.

Any tips around that?

woole

Swoole => enabled Author => Swoole Team team@swoole.com Version => 4.7.1 Built => Sep 20 2021 15:04:35 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled pcre => enabled mutex_timedlock => enabled pthread_barrier => enabled futex => enabled async_redis => enabled

Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => On => On swoole.unixsock_buffer_size => 8388608 => 8388608

swoole' => [ 'daemonize' => env('LARAVELS_DAEMONIZE', false), 'dispatch_mode' => 1, 'reactor_num' => env('LARAVELS_REACTOR_NUM', function_exists('swoole_cpu_num') ? swoole_cpu_num() 2 : 4), 'worker_num' => env('LARAVELS_WORKER_NUM', function_exists('swoole_cpu_num') ? swoole_cpu_num() 2 : 8), //'task_worker_num' => env('LARAVELS_TASK_WORKER_NUM', function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 8), 'task_ipc_mode' => 1, 'task_max_request' => env('LARAVELS_TASK_MAX_REQUEST', 8000), 'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',

    /** max_request is "per worker"
     * It will restart only the workers whose executed requests number get to around the max_request number
     * (Around as it sets a random number to avoid stopping multiple workers at the same time)
     */
    'max_request' => env('LARAVELS_MAX_REQUEST', 3000),
    'open_tcp_nodelay' => true,
    'pid_file' => storage_path('laravels.pid'),
    'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))),
    'log_level' => 4,
    'document_root' => base_path('public'),
    'buffer_output_size' => 2 * 1024 * 1024,
    'socket_buffer_size' => 128 * 1024 * 1024,
    'package_max_length' => 10 * 1024 * 1024, //This limits the max upload file size. Unit is bytes
    'reload_async' => true,
    'max_wait_time' => 60,
    'enable_reuse_port' => true,
    'enable_coroutine' => false,
    'http_compression' => false,