Raw
1 ---
2 sidebar_label: "start"
3 sidebar_position: 3
4 ---
5
6 import { Table } from "docs-ui"
7
8 export const metadata = {
9 title: `start Command - Medusa CLI Reference`,
10 }
11
12 # {metadata.title}
13
14 Start the Medusa application in production.
15
16 ```bash npx2yarn
17 npx medusa start
18 ```
19
20 ## Options
21
22 <Table>
23 <Table.Header>
24 <Table.Row>
25 <Table.HeaderCell>
26 Option
27 </Table.HeaderCell>
28 <Table.HeaderCell>
29 Description
30 </Table.HeaderCell>
31 <Table.HeaderCell>
32 Default
33 </Table.HeaderCell>
34 </Table.Row>
35 </Table.Header>
36 <Table.Body>
37 <Table.Row>
38 <Table.Cell>
39
40 `-H <host>`, `--host <host>`
41
42 </Table.Cell>
43 <Table.Cell>
44
45 Set host of the Medusa server.
46
47 </Table.Cell>
48 <Table.Cell>
49
50 `localhost`
51
52 </Table.Cell>
53 </Table.Row>
54 <Table.Row>
55 <Table.Cell>
56
57 `-p <port>`, `--port <port>`
58
59 </Table.Cell>
60 <Table.Cell>
61
62 Set port of the Medusa server.
63
64 </Table.Cell>
65 <Table.Cell>
66
67 `9000`
68
69 </Table.Cell>
70 </Table.Row>
71 <Table.Row>
72 <Table.Cell>
73
74 `--cluster <string> [--workers <string>] [--servers <string>]`
75
76 </Table.Cell>
77 <Table.Cell>
78
79 Start Medusa in cluster mode. Learn more in the [Starting Medusa in Cluster Mode](#starting-medusa-in-cluster-mode) section.
80
81 </Table.Cell>
82 <Table.Cell>
83
84 Cluster mode is disabled by default. If the option is passed but no number or percentage is passed, Medusa will try to consume all available CPU cores.
85
86 </Table.Cell>
87 </Table.Row>
88 </Table.Body>
89 </Table>
90
91 ---
92
93 ## Starting Medusa in Cluster Mode
94
95 <Note>
96
97 Prior to [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0), the `--cluster` option accepted a number value only. You can now pass either a number or a percentage value, and you can also specify the number of servers and workers.
98
99 </Note>
100
101 Medusa supports starting the Node.js server in [cluster mode](https://expressjs.com/en/advanced/best-practice-performance.html#run-your-app-in-a-cluster), which significantly improves performance as the workload and tasks are distributed among all available instances instead of a single one.
102
103 Cluster mode is disabled by default. To enable it, pass the `--cluster` option when starting Medusa:
104
105 ```bash npx2yarn
106 npx medusa start --cluster
107 ```
108
109 When the `--cluster` option is passed without a number or percentage value, Medusa will try to consume all available CPU cores.
110
111 ### Specify Number or Percentage of CPU Cores
112
113 You can specify the number or percentage of CPU cores to be used by passing a number or percentage value to the `--cluster` option:
114
115 ```bash npx2yarn
116 npx medusa start --cluster 2 # Use 2 CPU cores
117 npx medusa start --cluster 50% # Use 50% of available CPU
118 ```
119
120 ### Specify Number of Servers and Workers
121
122 When running Medusa in cluster mode, you can specify the number or percentage of instances that are [servers or workers](!docs!/learn/production/worker-mode) by passing the `--servers` and `--workers` options:
123
124 ```bash npx2yarn
125 npx medusa start --cluster 4 --servers 25% --workers 75% # Use 4 CPU cores, with 25% as servers and 75% as workers
126 npx medusa start --cluster 4 --servers 1 --workers 3 # Use 4 CPU cores, with 1 as server and 3 as workers
127 npx medusa start --cluster 4 --servers 1 --workers 1 # Use 4 CPU cores, with 1 as server and 1 as worker (the remaining 2 will run in shared mode)
128 ```
129
130 When the number or percentage of servers and workers don't add up to the total number of instances in cluster mode, the remaining instances will run in shared mode.
131
132 <Note>
133
134 Learn more in the [Worker Mode](!docs!/learn/production/worker-mode) guide.
135
136 </Note>