Skip to content

[doc] add elastica populate bundle #155

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

Merged
merged 1 commit into from
Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions docs/elastica-bundle/populate-command-optimization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Enqueue Elastica Bundle

Improves performance of `fos:elastica:populate` commands by distributing the work among consumers.
The performance gain depends on how much consumers you run.
For example 10 consumers may give you 5 to 7 times better performance.

## Installation

Install packages using [composer](https://getcomposer.org/)

```bash
$ composer require enqueue/elastica-bundle friendsofsymfony/elastica-bundle
```

Add bundles to `AppKernel`

```php
<?php
use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...

new Enqueue\Bundle\EnqueueBundle(),
new Enqueue\ElasticaBundle\EnqueueElasticaBundle(),
new FOS\ElasticaBundle\FOSElasticaBundle(),
];

return $bundles;
}
}
```

Here's an example of what your `FOSElasticaBundle` configuration may look like:

```yaml
fos_elastica:
clients:
default: { host: %elasticsearch_host%, port: %elasticsearch_port% }
indexes:
app:
index_name: app_%kernel.environment%
types:
blog:
mappings:
text: ~
persistence:
driver: orm
model: AppBundle\Entity\Blog
provider: ~
listener: ~
finder: ~
```

Here's an example of what your EnqueueBundle configuration may look like:

```yaml
enqueue:
transport:
default: 'file://%kernel.root_dir%/../var/messages'
```

Sure you can configure other transports like: [rabbitmq, amqp, stomp and so on](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/bundle/config_reference.md)
Create a `fos_elastica_populate` queue on broker side, if needed.

## Usage

The bundle once registered automatically replaces Doctrine ORM provider by async one.
So you have to run as usual

```bash
$ ./bin/console fos:elastica:populate
```

If you want to disable this behavior you can un register the bundle or use env var

```bash
$ ENQUEUE_ELASTICA_DISABLE_ASYNC=1 ./bin/console fos:elastica:populate
```

Run some consumers either using client (you might have to enable it) consume command:

```bash
$ ./bin/console enqueue:consume --setup-broker -vvv
```

or a transport one:

```bash
$ ./bin/console enqueue:transport:consume enqueue_elastica.populate_processor -vvv
```

We suggest to use [supervisor](http://supervisord.org/) on production to control numbers of consumers and restart them.

Here's config example

```
# cat /etc/supervisor/conf.d/fos_elastica_populate.conf
[program:fos_elastica_populate]
command=/mqs/symfony/bin/console enqueue:transport:consume fos_elastica_populate enqueue_elastica.populate_processor
process_name=%(program_name)s_%(process_num)02d
numprocs=10
autostart=true
autorestart=true
startsecs=0
user=root
redirect_stderr=true
```

[back to index](../index.md)
9 changes: 5 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@
- [Consumption extension](bundle/consumption_extension.md)
- [Production settings](bundle/production_settings.md)
- [Debuging](bundle/debuging.md)
- [Functional testing](bundle/functional_testing.md)
* Async event dispatcher (Symfony)
- [Quick tour](async_event_dispatcher/quick_tour.md)
- [Functional testing](bundle/functional_testing.md)
* Laravel
- [Quick tour](laravel/quick_tour.md)
- [Queues](laravel/queues.md)
* Magento
- [Quick tour](magento/quick_tour.md)
- [Cli commands](magento/cli_commands.md)
- [Cli commands](magento/cli_commands.md)
* [Use cases]
- [FOSElasticaBundle. Populate command optimizations](elastica-bundle/populate-command-optimization.md)
- [Symfony. Async event dispatcher](async_event_dispatcher/quick_tour.md)
* Development
- [Contribution](contribution.md)

Expand Down