Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 286 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Redis for Queues for Multiple Laravel Applications on a Single Server

#1
I have a production laravel application and the staging application running on the same server. I am running redis, which I am using as my queue driver. They are obviously connected to different databases. The question is if jobs that are pushed onto the reds queue from the staging application will interfere with the production db and vice versa.
Reply

#2
You can set the prefix Laravel uses for the Redis cache. By default this is `laravel`, so all keys are stored as `laravel:keyname` and Laravel takes care of the logic to add/remove this prefix when saving/getting.

You can set the prefix in `config/cache.php`. You could leave the main one as `laravel` and set your staging app prefix to `stage` or something. This will mean multiple Laravel apps can use the same Redis instance.
Reply

#3
I had this same problem, and it took me hours to find the solution.

[To see links please register here]

says:

> In order to use the `redis` queue driver, you should configure a Redis
> database connection in your `config/database.php` configuration file.

And then

[To see links please register here]

says:

> In addition to the default `host`, `port`, `database`, and `password` server
> configuration options, Predis supports additional [connection parameters][1] that may be defined for each of your Redis servers. To
> utilize these additional configuration options, add them to your Redis
> server configuration in the `config/database.php` configuration file.

Reading the "connection parameters" page, I eventually found

[To see links please register here]

, which says that 'prefix' is a supported option.

So, you can edit your `config/database.php` configuration file to have:

'redis' => [
'client' => 'predis',
'cluster' => false,
'options'=>[
'prefix' => env('REDIS_PREFIX', 'YOUR_PREFIX_HERE')
],
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],

I'm not sure if you then need to restart Redis or Supervisord.

[1]:

[To see links please register here]

Reply

#4
As of [Laravel 5.5.22](

[To see links please register here]

) the cache prefix is using the `APP_NAME` environment variable. You can rely on that if that's enough or alternatively you may configure the prefix by using the `CACHE_PREFIX` environment variable that is not set by default.

[![`CACHE_PREFIX`][1]][1]

If you're using Laravel Horizon to manage your queues, you can simply override the `HORIZON_PREFIX` environment variable to let Horizon differentiate between your applications running side by side.

[![`HORIZON_PREFIX`][2]][2]


[1]:

[2]:
Reply

#5
You can set the default Laravel queue in .env for the Redis.



REDIS_QUEUE=your_app1_queuename


By default this is '**default**',

this used in config/queue.php. This will mean multiple Laravel apps can use the same Redis instance.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through