title: Php , laravel, socket -Horizontal scaling technique
body: <p>I have a laravel app, and in it I am using php ratchet library to have persistent connection between client and the user for real time communication(for now it is just one way, i.e. , only the server can send a message to client).</p>
  
  <p>With this architecture , how can I have multiple of these laravel servers , each having their own set of clients connected to them , to inter communicate? </p>
  
  <p>I am thinking about using REDIS , and having a redis server , which all my nodes will connect to (using pub sub). </p>
  
  <p>My service is similar to a group messaging app (one user has many groups , and one group has many users ), and so far (right now I have a single server and no redis) , I get all the user's groups , and subscribe him to those topics (with topic name something like GROUP_ 1,GROUP_ 8 ,GROUP_ 99 etc). </p>
  
  <p>I would like to know how each node can subscribe to specific topics in redis (it would not make sense to send ALL redis messages to ALL my nodes ).</p>
  
  <p>Laravel's Example says to use a php artisan command like so:</p>
  
  <pre><code>class RedisSubscribe extends Command
  {
      /**
       * The name and signature of the console command.
       *
       * @var string
       */
      protected $signature = 'redis:subscribe';
  
      /**
       * The console command description.
       *
       * @var string
       */
      protected $description = 'Subscribe to a Redis channel';
  
      /**
       * Execute the console command.
       *
       * @return mixed
       */
      public function handle()
      {
          Redis::subscribe(['test-channel'], function($message) {
              echo $message;
          });
      }
  }
  </code></pre>
  
  <p>But , I want to be able to subscribe , unsubscribe from certain topics at runtime(after the artisan command was run). How can I do that in laravel ?</p>