I have made an instagram contender that needs to be able to process video conversions(FFMPEG) on a different server because of CPU reasons.
Both of my servers are connected by the same database.
Currently i have a local redis server working so this way i can push tasks to the background using the default redis config/queue config/database.
All of it is working so far, now i want to go to the next step and set-up a bridge to pass off the intensive tasks to a dedicated server just for doing video processing tasks.
To sum up what i want
1.Dispatch job from SERVER1 and send it to SERVER2 REDIS QUEUE to be processed
SERVER1(default) connection (config/queue) for redis
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
],
SERVER1(default) queue (config/database)
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
What i have attempted
SERVER2 Connection
'videoProcessingRedis' => [
'driver' => 'redis',
'connection' => 'videoRedisQueue',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
],
SERVER 2 Queue
'videoRedisQueue' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', 'https://website.ca/'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
Jobs/ConvertVideoForHLS
public function __construct(video $video)
{
$this->onConnection('videoProcessingRedis');
$this->onQueue('videoRedisQueue');
$this->video = $video;
}
With the above attempt set i do not get any errors, however i can not view the job or even see that it has been created. even using the php artisan queue:listen and php artisan queue:listen videoProcessingRedis i can not see anything, nothing in the failed_jobs table and nothing in my supervisor.log so im assuming its got something to do with it just bouncing off the host?
Idea 1
Set SERVER2 redis server to be public facing
1.set the bind option on the /etc/redis/redis.conf file
before
bind 127.0.0.1
after
bind 0.0.0.0
after bind has been set(allowing all access) i would add a port restriction on 6379 with only the SERVER1 IP to be able to connect
When working with multiple servers on a Redis queue you need to make sure that the APP_NAME variable of both environments have the same value. If those are different then the worker will not see the jobs.
To check if your connection is working you could run redis-cli -h {ip-of-server-2} from server 1.
Related
Horizon Version: 3.7.2 / 3.4.7
Laravel Version: 6.17.0
PHP Version: 7.4.4
Redis Driver & Version: predis 1.1.1 / phpredis 5.2.1
Database Driver & Version: -
We are having strange errors with our Horizon. Basically this is what happens:
- A job is queued. And starts processing.
After 90 seconds (our timeout config value) it times out.
After 120 seconds (our retry_after value) job is retried.
Retried job succeeds.
After 15 minutes or 30 minutes, the original job(the one timed out) finishes. With running the actual job.
Seems like this can happen to any kind of job. For example if it's mailable that is queued, the user gets an email first, then 15 or 30 minutes later user gets another email. Same one.
Here our config files
config/database.php:
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'),
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
config/queue.php:
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('DEFAULT_QUEUE_NAME', 'default'),
'retry_after' => 120, // 2 minutes
'block_for' => null,
],
config/horizon.php:
'environments' => [
'production' => [
'supervisor-1' => [
'connection' => env('HORIZON_CONNECTION', 'redis'),
'queue' => [env('DEFAULT_QUEUE_NAME', 'default')],
'balance' => 'simple',
'processes' => 10,
'tries' => 3,
'timeout' => 90,
],
],
]
Here how it looks in Horizon Dashboard
This when the initial job times out. It stays like this in Recent Jobs while the retries are working.
After almost half an hour it changes to this:
It's the same tags, I just blacked out names.
Here are the logs we are seeing (times here are in UTC)
[2020-04-22 11:24:59][88] Processing: App\Mail\ReservationInformation
[2020-04-22 11:29:00][88] Failed: App\Mail\ReservationInformation
[2020-04-22 11:29:00][88] Processing: App\Mail\ReservationInformation
[2020-04-22 11:56:21][88] Processed: App\Mail\ReservationInformation
Note: With Predis we also see some logs like Error while reading line from the server. [tcp://REDIS_HOST:6379] but with PHPRedis there was none.
We tried a lot of different combinations, to eliminate the problem. And it happened in every combination. So we think it must be something with Horizon.
We tried:
- Predis with Redis 5 and Redis 3
Predis with different read_write_timeout values
PHPRedis with Redis 5 and Redis 3
THP was enabled on one server. So we also tried all combinations with a server that has THP disabled.
We were at Laravel 6.11 and Horizon 3.4.7 then upgraded to Laravel 6.14 and Horizon 3.7.2
There is only one instance of Horizon running. And no other queue is handled in this Horizon instance.
Any information or tips to try are welcome!
For us this turned out to be a configuration error in our systems. We were using OpenShift and Docker. We adjusted these values in our containers/systems
net.ipv4.tcp_keepalive_intvl
net.ipv4.tcp_keepalive_probes
net.ipv4.tcp_keepalive_time
and for now everything works normally.
Running Laravel 5.7 via Homestead.
This is happening in:
/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php
"line":66
"function":"establishConnection"
We are using PHP Redis and in config/database.php:
'redis' => [
'client' => 'phpredis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 6,
],
],
I've seen other answers on here and none of the steps work. There is no redis cluster in use. PhpRedis extension is installed on VM and confirmed with php -m. Redis server is running at 127.0.0.1 and can be connected to outside of the code.
I'm unable to change the code as it works for others. It must be a configuration issue on my VM but I can't see what it could be. If anyone has had a similar issue I'd much appreciate any advice.
The problem you are having is because of class naming conflict: PhpRedisConnector creates new \Redis client, but it seems that you have alias for Illuminate\Support\Facades\Redis facade set up somewhere in your app. PhpRedisConnector creates new Redis and gets facade object instead.
Try removing this line in your config/app.php:
'aliases' => [
...
'Redis' => Illuminate\Support\Facades\Redis::class, // remove this line
...
]
I'm trying to connect Laravel with a multiple sqlserver databases, I defined the connections on my database.php file correctly :
'connections' => [
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '16000'),
'database' => env('DB_DATABASE', 'dbname'),
'username' => env('DB_USERNAME', 'me'),
'password' => env('DB_PASSWORD', 'me'),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
'sqlsrv2' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '16000'),
'database' => env('DB_DATABASE_2', 'dbname2'),
'username' => env('DB_USERNAME', 'me'),
'password' => env('DB_PASSWORD', 'me'),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
],
and set my .env file
DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1
DB_PORT=16000
DB_DATABASE=dbname
DB_USERNAME=me
DB_PASSWORD=me
I try to verify the connectivity to my sql server database from another application and it's working perfectly. then I created a model on my laravel application and once I type php artisan migrate I get this error :
anyone can help to resolve this problem ?
UPDATE !
After adding pdo sqlsrv extensions to my ext folder and my php.ini i get this error :
[![enter image description here][2]][2]
[![enter image description here][3]][3]
UPDATE 3 :
After installing odbc 13 i got this problem
Ah, WAMPServer has 2 seperate php.ini files.
One is used by PHP under Apache and the other by the PHP CLI.
I see you are using the CLI, so you need to check that you have included the SQL Server drivers extension in the CLI php.ini file.
You will find that in:
C:\wamp64\bin\php\php{version}\php.ini
You have to edit this manually, there is no menu link to do this, the menu link to edit the php.ini only edits the PHP under Apache version of php.ini
Make sure you edit the php.ini file in the folder that matches the version of PHP you are actually using for this project, as of course you can have multiple versions of PHP installed under WAMPServer
UPDATE: Second Problem
You have added the 32bit AND 64 bit SQL Server drivers to your ext folder!
Your WAMPServer menu shows
1. php_sqlsrv_72_ts_x64
2. php_sqlsrv_72_ts_x32
3. php_pdo_sqlsrv_72_ts_x64
4. php__pdo_sqlsrv_72_ts_x32
as you are using 64 bit wamp, you should only have these 2
1. php_sqlsrv_72_ts_x64
2. php_pdo_sqlsrv_72_ts_x64
I am using laravel 5.2 and having an architecture of multi-server autoscaling. I want to have session and cache in a centralized location. I want to use AWS elasticache for the same.
I have setup an elasticache Redis cluster having following options :
Parameter group : default.redis.3.2.cluster.on
Shards : 3
Total Nodes : 9
In laravel session configuration I have set redis as the session driver.
In database.php where redis configuration is set, i have used following :
REDIS_HOST=my_aws_elasticache_configuration_endpoint
REDIS_PASSWORD=null
REDIS_PORT=6379
.
When I try to use it, I get following error :
MOVED 13841 some_ip_address_of_aws:6379
I tried using local redis and it worked, so predis is working properly. I tried to check the solutions online, but not able to get the solution. I believe that the configuration endpoint is trying to redirect the redis connection to an available node url out of the 9 nodes I have. However, I have anticipated that AWS should do it internally and not throw exception. Can anyone help me?
I finally got an answer, we need to get the cluster mode on in database settings and set new cluster option to redis. This is how the redis config in database.php looks like :
'redis' => [
'client' => 'predis',
'options' => [
'cluster' => 'redis',
],
'clusters' => [
'default' => [
[
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
],
],
If you have password then you can replace options array with this :
'options' => [
'cluster' => 'redis',
'parameters' => ['password' => env('REDIS_PASSWORD', null)],
],
Attempting to connect to an Oracle database with yajra/laravel-oci8, below is the configuration. Note that I've also installed the instant client 11g corresponding to the bit version of Windows Server. I've ensured that the 11g ext is enabled in the php.ini.
Spent 4 days on this now, does anybody have any idea what's going on?
I don't even get an error message, just a stack dump which is attached.
'oracle' => [
'driver' => 'oracle',
'tns' => 'LISTENER',
'host' => '192.168.39.73',
'port' => env('DB_PORT', '1521'),
'database' => 'QORA',
'username' => 'ETEST',
'password' => 'ETEST',
'charset' => env('DB_CHARSET', 'AL32UTF8'),
'prefix' => env('DB_PREFIX', ''),
'prefix_schema' => env('DB_SCHEMA_PREFIX', ''),
],
Your error messages are showing you are trying to connect on port 3306, which is the standard MySQL port. According to your config, you're looking at the DB_PORT value from the .env file, with a backup of 1521 if that doesn't exist.
My guess is that your .env file has the following line:
DB_PORT=3306
You either need to comment or remove that line, or change 3306 to 1521.