You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a simple chat application and I discovered that dispatch(new ChatMessage)->toOthers() (even without the toOthers part) slows my request by approximatively 160ms. I'm using the database driver for queues but the same problem occurs in production where I'm using redis.
My app is quite simple and my NewChatMessage only contains:
<?php
namespace App\Events;
use App\Models\ChatMessage;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\SerializesModels;
class NewChatMessage implements ShouldBroadcastNow, ShouldBeUnique
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
public function __construct(ChatMessage $message)
{
$this->message = $message;
}
public function handle()
{
}
public function broadcastOn()
{
return new PresenceChannel('chat.'.$this->message->room_id);
}
}
I tried removing the data from the events (the $message instance) and nothing changed.
Broadcasting happens through pusher on development stage for dev and production paid plan for production.
Tried with and without caching events, no difference.
Any idea on this? Anyone encountered this problem?
Edit: BroadcastNow uses sync, whenever I remove the Now part, the request is faster, but my server configuration/project can't handle so much jobs in the queue (everything gets delayed easily).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm building a simple chat application and I discovered that
dispatch(new ChatMessage)->toOthers()
(even without thetoOthers
part) slows my request by approximatively 160ms. I'm using the database driver for queues but the same problem occurs in production where I'm using redis.My app is quite simple and my
NewChatMessage
only contains:I tried removing the data from the events (the
$message
instance) and nothing changed.Broadcasting happens through pusher on development stage for dev and production paid plan for production.
Tried with and without caching events, no difference.
Any idea on this? Anyone encountered this problem?
Edit: BroadcastNow uses sync, whenever I remove the
Now
part, the request is faster, but my server configuration/project can't handle so much jobs in the queue (everything gets delayed easily).King regards.
Beta Was this translation helpful? Give feedback.
All reactions