Skip to content

Latest commit

 

History

History
107 lines (86 loc) · 4.52 KB

4. Service Configuration.md

File metadata and controls

107 lines (86 loc) · 4.52 KB

Service Configuration

4.1 Demonstrate ability to create service configurations

How to add system services: MySQL, Redis, Elasticsearch, RabbitMQ

For Pro projects, the changes you make using this YAML file affects your Integration environment only. To make these changes in a Staging or Production environment, you must create a Support ticket.

Defining services

.magento/services.yaml file used to configure your services.

mysql:
    type: mysql:10.2
    disk: 2048
    configuration:
        schemas:
            - main
            - legacy
        endpoints:
            mysql:
                default_schema: main
                privileges:
                    main: admin
            mbi:
                default_schema: main
                privileges:
                    main: ro
            importer:
                default_schema: legacy
                privileges:
                    main: rw
        properties:
            max_allowed_packet: 64

redis:
    type: redis:3.0

elasticsearch:
    type: elasticsearch:6.5
    disk: 1024
   configuration:
    plugins:
      - analysis-icu
      - lang-python

rabbitmq:
    type: rabbitmq:3.5
    disk: 1024

Using services

For services to be available to an application in your project, you must specify relationships between applications and services in .magento.app.yaml.

The left-hand side is the name of the relationship as it will be exposed to the application in the MAGENTO_CLOUD_RELATIONSHIPS variable. The right-hand side is in the form <service name>:<endpoint name>. Where <service name> comes from .magento/services.yaml. The <endpoint name> is the exposed functionality of the service to use. For most services that is simply the same as the service type, but on MySQL, for example, could be different if the service is running multiple databases (see configuration.endpoints).

relationships:
    database: "mysql:mysql"
    mbi: "mysql:mbi"
    imports: "mysql:importer"
    redis: "redis:redis"
    elasticsearch: "elasticsearch:elasticsearch"
    rabbitmq: "rabbitmq:rabbitmq"

4.2 Demonstrate ability to use Slave connections

How to leverage slave connections to MySQL, Redis
  1. Add next options in the .magento.env.yaml file
stage:
  deploy:
      MYSQL_USE_SLAVE_CONNECTION: true
      REDIS_USE_SLAVE_CONNECTION: true
  1. Create next variables (MYSQL_USE_SLAVE_CONNECTION, REDIS_USE_SLAVE_CONNECTION)
magento-cloud variable:create --level=environment --value=true --inheritable=false --json=false --prefix=none MYSQL_USE_SLAVE_CONNECTION
magento-cloud variable:create --level=environment --value=true --inheritable=false --json=false --prefix=none REDIS_USE_SLAVE_CONNECTION

REDIS_USE_SLAVE_CONNECTION used by ece-tools Config/Factory/Cache

Magento can read multiple Redis instances asynchronously. Set to true to automatically use a read-only connection to a Redis instance to receive read-only traffic on a non-master node. This improves performance through load balancing, because only one node needs to handle read-write traffic. Set to false to remove any existing read-only connection array from the env.php file.

MYSQL_USE_SLAVE_CONNECTION used by ece-tools Config/Database/MergedConfig and get credentials by Config/Database/SlaveConfig

Magento can read multiple databases asynchronously. Set to true to automatically use a read-only connection to the database to receive read-only traffic on a non-master node. This improves performance through load balancing, because only one node needs to handle read-write traffic. Set to false to remove any existing read-only connection array from the env.php file.

Documentation: