# Gearman, ElastiCache, and the MCP server/client

Archivematica also has microservices in the sense we use them in the rest of the platform: independent containers running in ECS.

![](https://681624210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDAM268qVZ2nrq3bsj6TI%2Fuploads%2Fgit-blob-5fedc1373f78f1729ccacb21182f6c4499106b2b%2Fmcp_architecture.svg?alt=media)

The *MCP server* is a scheduler written as part of Archivematica. It decides what tasks (in the sense described above) need to be run. It tells the *Gearman server* about these tasks.

*Gearman* is [an open-source framework](http://gearman.org/) for distributing tasks between machines. It uses Redis as a database to track the in-flight tasks, which in our case is an instance of Amazon hosted ElastiCache.

The *MCP client* picks up tasks from Gearman, and actually does the work -- for example, moving a file from A to B. It then reports the results back to Gearman. You can have multiple instances of the MCP client, and the computational resources available to each client are a dominant factor in the speed of processing in Archivematica. At time of writing (March 2020), we run two instances of the MCP client.

So the lifecycle of a task is as follows:

* The MCP server schedules a task, and sends it to Gearman
* Gearman forwards the task to an MCP client
* The MCP client performs the task, and reports the result back to Gearman
* Gearman forwards the result to the MCP server, which then displays the result in the dashboard, and decides what task to run next

These services write the result of their processing to a MySQL database, which uses RDS.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wellcomecollection.org/archivematica/service-architecture/how-does-archivematica-work/gearman-elasticache-and-the-mcp-server-client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
