Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preventing application slowing down #5

Closed
klemenskarssen opened this issue Dec 3, 2014 · 2 comments
Closed

Preventing application slowing down #5

klemenskarssen opened this issue Dec 3, 2014 · 2 comments

Comments

@klemenskarssen
Copy link

Hi Maknz,

thanks for the nice PHP package. Since yesterday I'm using it in my Laravel app.

Everything is working fine. However I'm noticing that my app is around 300ms per request slower with Slack on. In New Relic I also see higher load times due to Slack.

It seems that it is waiting for the response of the Slack webhook before continuing the rest of the code. I'm using the following code:
Slack::send($message);

Is there a way that the Laravel app doesn't have to wait till the Slack send command has finished? For example, can I queue the message?

Cheers, Klemens

@maknz
Copy link
Owner

maknz commented Dec 3, 2014

Hi @klemenskarssen,

Since PHP isn't async, the web request to Slack will block until a response is returned, so seeing a 300ms slow down per request is expected.

As you suggested, a queue is the way to go here. I have a whole queue job class for the different Slack messages we put out, but as a simplistic example:

$message = 'Hello world';

Queue::push(function($job) use ($message)
{
    Slack::send($message);

    $job->delete();
});

You can read all about Laravel's queueing functionality here: http://laravel.com/docs/4.2/queues

@maknz maknz closed this as completed Dec 3, 2014
@klemenskarssen
Copy link
Author

Hi @maknz,
thanks for the quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants