-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (101 loc) · 3.78 KB
/
Makefile
File metadata and controls
126 lines (101 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
.PHONY: help install \
services services-stop \
pass-through pass-through-stop \
trie trie-stop trie-bench \
lb lb-backends lb-backends-stop lb-gateway lb-gateway-stop lb-stop lb-bench lb-chaos \
stop-all
### Help ###
help:
@echo ""
@echo " api-gateway Makefile"
@echo " ========================================"
@echo ""
@echo " Setup:"
@echo " make install install pip dependencies"
@echo ""
@echo " Services (dummy backends):"
@echo " make services start users :8001 + orders :8002"
@echo " make services-stop kill them"
@echo ""
@echo " Pass-Through phase:"
@echo " make pass-through start gateway :8080 (needs services running)"
@echo " make pass-through-stop kill gateway"
@echo ""
@echo " Trie Routing phase:"
@echo " make trie start gateway :8080 (needs services running)"
@echo " make trie-stop kill gateway"
@echo " make trie-bench run trie vs dict benchmark (no servers needed)"
@echo ""
@echo " Load Balancing phase:"
@echo " make lb start 6 backends + gateway (all-in-one)"
@echo " make lb-backends start 6 backends only"
@echo " make lb-gateway start gateway only"
@echo " make lb-stop kill everything"
@echo " make lb-bench run algorithm benchmark (no servers needed)"
@echo " make lb-chaos run chaos demo (starts its own servers)"
@echo ""
@echo " Cleanup:"
@echo " make stop-all kill all background processes"
@echo ""
### Setup ###
install:
pip install -r requirements.txt
### Services (shared backends for pass_through & trie_routing) ###
services:
@echo "Starting Users backend :8001 ..."
@cd services/src && python users.py &
@echo "Starting Orders backend :8002 ..."
@cd services/src && python orders.py &
@sleep 1
@echo "Backends ready."
services-stop:
@echo "Stopping services..."
@-pkill -f "users.py" 2>/dev/null || true
@-pkill -f "orders.py" 2>/dev/null || true
@echo "Done."
### Pass-Through ###
pass-through: services
@echo "Starting pass-through gateway :8080 ..."
@cd pass_through/src && python api_gateway.py
pass-through-stop:
@-pkill -f "pass_through/src/api_gateway.py" 2>/dev/null || true
### Trie Routing ###
trie: services
@echo "Starting trie-routing gateway :8080 ..."
@cd trie_routing/src && python api_gateway.py
trie-stop:
@-pkill -f "trie_routing/src/api_gateway.py" 2>/dev/null || true
trie-bench:
@echo "Running trie vs dict benchmark..."
@cd trie_routing/src && python benchmark.py
### Load Balancing ###
lb-backends:
@echo "Starting 6 backends..."
@cd load_balancing/src && python backend.py 8001 users &
@cd load_balancing/src && python backend.py 8003 users &
@cd load_balancing/src && python backend.py 8005 users &
@cd load_balancing/src && python backend.py 8002 orders &
@cd load_balancing/src && python backend.py 8004 orders &
@cd load_balancing/src && python backend.py 8006 orders &
@sleep 2
@echo "All 6 backends ready."
lb-gateway:
@echo "Starting load-balanced gateway :8080 ..."
@cd load_balancing/src && python api_gateway.py
lb: lb-backends
@echo "Starting load-balanced gateway :8080 ..."
@cd load_balancing/src && python api_gateway.py
lb-backends-stop:
@-pkill -f "backend.py" 2>/dev/null || true
lb-gateway-stop:
@-pkill -f "load_balancing/src/api_gateway.py" 2>/dev/null || true
lb-stop: lb-backends-stop lb-gateway-stop
lb-bench:
@echo "Running load balancer benchmark..."
@cd load_balancing/src && python benchmark.py
lb-chaos:
@echo "Running chaos demo (starts its own servers)..."
@cd load_balancing/src && python chaos_demo.py
### Nuke everything ###
stop-all: services-stop pass-through-stop trie-stop lb-stop
@echo "All processes stopped."