Skip to content

Commit 87c2633

Browse files
committed
[doc] add elastica populate bundle
1 parent 3403f7e commit 87c2633

File tree

2 files changed

+119
-4
lines changed

2 files changed

+119
-4
lines changed
+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Enqueue Elastica Bundle
2+
3+
Improves performance of `fos:elastica:populate` commands by distributing the work among consumers.
4+
The performance gain depends on how much consumers you run.
5+
For example 10 consumers may give you 5 to 7 times better performance.
6+
7+
## Installation
8+
9+
Install packages using [composer](https://getcomposer.org/)
10+
11+
```bash
12+
$ composer require enqueue/elastica-bundle friendsofsymfony/elastica-bundle
13+
```
14+
15+
Add bundles to `AppKernel`
16+
17+
```php
18+
<?php
19+
use Symfony\Component\HttpKernel\Kernel;
20+
21+
class AppKernel extends Kernel
22+
{
23+
public function registerBundles()
24+
{
25+
$bundles = [
26+
// ...
27+
28+
new Enqueue\Bundle\EnqueueBundle(),
29+
new Enqueue\ElasticaBundle\EnqueueElasticaBundle(),
30+
new FOS\ElasticaBundle\FOSElasticaBundle(),
31+
];
32+
33+
return $bundles;
34+
}
35+
}
36+
```
37+
38+
Here's an example of what your `FOSElasticaBundle` configuration may look like:
39+
40+
```yaml
41+
fos_elastica:
42+
clients:
43+
default: { host: %elasticsearch_host%, port: %elasticsearch_port% }
44+
indexes:
45+
app:
46+
index_name: app_%kernel.environment%
47+
types:
48+
blog:
49+
mappings:
50+
text: ~
51+
persistence:
52+
driver: orm
53+
model: AppBundle\Entity\Blog
54+
provider: ~
55+
listener: ~
56+
finder: ~
57+
```
58+
59+
Here's an example of what your EnqueueBundle configuration may look like:
60+
61+
```yaml
62+
enqueue:
63+
transport:
64+
default: 'file://%kernel.root_dir%/../var/messages'
65+
```
66+
67+
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)
68+
Create a `fos_elastica_populate` queue on broker side, if needed.
69+
70+
## Usage
71+
72+
The bundle once registered automatically replaces Doctrine ORM provider by async one.
73+
So you have to run as usual
74+
75+
```bash
76+
$ ./bin/console fos:elastica:populate
77+
```
78+
79+
If you want to disable this behavior you can un register the bundle or use env var
80+
81+
```bash
82+
$ ENQUEUE_ELASTICA_DISABLE_ASYNC=1 ./bin/console fos:elastica:populate
83+
```
84+
85+
Run some consumers either using client (you might have to enable it) consume command:
86+
87+
```bash
88+
$ ./bin/console enqueue:consume --setup-broker -vvv
89+
```
90+
91+
or a transport one:
92+
93+
```bash
94+
$ ./bin/console enqueue:transport:consume enqueue_elastica.populate_processor -vvv
95+
```
96+
97+
We suggest to use [supervisor](http://supervisord.org/) on production to control numbers of consumers and restart them.
98+
99+
Here's config example
100+
101+
```
102+
# cat /etc/supervisor/conf.d/fos_elastica_populate.conf
103+
[program:fos_elastica_populate]
104+
command=/mqs/symfony/bin/console enqueue:transport:consume fos_elastica_populate enqueue_elastica.populate_processor
105+
process_name=%(program_name)s_%(process_num)02d
106+
numprocs=10
107+
autostart=true
108+
autorestart=true
109+
startsecs=0
110+
user=root
111+
redirect_stderr=true
112+
```
113+
114+
[back to index](../index.md)

Diff for: docs/index.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@
3535
- [Consumption extension](bundle/consumption_extension.md)
3636
- [Production settings](bundle/production_settings.md)
3737
- [Debuging](bundle/debuging.md)
38-
- [Functional testing](bundle/functional_testing.md)
39-
* Async event dispatcher (Symfony)
40-
- [Quick tour](async_event_dispatcher/quick_tour.md)
38+
- [Functional testing](bundle/functional_testing.md)
4139
* Laravel
4240
- [Quick tour](laravel/quick_tour.md)
4341
- [Queues](laravel/queues.md)
4442
* Magento
4543
- [Quick tour](magento/quick_tour.md)
46-
- [Cli commands](magento/cli_commands.md)
44+
- [Cli commands](magento/cli_commands.md)
45+
* [Use cases]
46+
- [FOSElasticaBundle. Populate command optimizations](elastica-bundle/populate-command-optimization.md)
47+
- [Symfony. Async event dispatcher](async_event_dispatcher/quick_tour.md)
4748
* Development
4849
- [Contribution](contribution.md)
4950

0 commit comments

Comments
 (0)