Skip to content

Commit

Permalink
finish spright benchmark
Browse files Browse the repository at this point in the history
Signed-off-by: lrq619 <[email protected]>
  • Loading branch information
lrq619 committed May 9, 2024
1 parent 5ffc945 commit 908c222
Show file tree
Hide file tree
Showing 19 changed files with 203 additions and 516 deletions.
3 changes: 0 additions & 3 deletions benchmarks/gg/benchmarks/llvm/llvm.tar.gz

This file was deleted.

4 changes: 2 additions & 2 deletions benchmarks/spright-parking/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ all: all-image

all-image: $(ALL_IMAGES)

parking-python-image: docker/Dockerfile python/server.py
parking-python-image:
DOCKER_BUILDKIT=1 docker buildx build \
--tag vhiveease/parking-python:latest \
--target parkingPython \
-f docker/Dockerfile \
-f docker/parking-python/Dockerfile \
$(ROOT) --load

push-%: %-image
Expand Down
64 changes: 64 additions & 0 deletions benchmarks/spright-parking/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

# Spright Benchmark

The spright benchmark is a set of parking slot functions(object detetction, searching, etc) adapted from: [spright](https://github.com/ucr-serverless/spright)
We implement a grpc-proxy so it can be invoked by vSwarm.


## Running this benchmark locally (using docker)

The detailed and general description how to run benchmarks local you can find [here](../../docs/running_locally.md). The following steps show it on the spright-python function.
1. Build or pull the function images using `make all-images` or `make pull`.
### Invoke once
2. Start the function with docker-compose
```bash
docker-compose -f ./yamls/docker-compose/dc-parking.yaml up
```
3. In a new terminal, invoke the interface function with grpcurl.
```bash
./tools/bin/grpcurl -plaintext localhost:50000 helloworld.Greeter.SayHello
```
### Invoke multiple times
2. Run the invoker
```bash
# build the invoker binary
cd ../../tools/invoker
make invoker
# Specify the hostname through "endpoints.json"
echo '[ { "hostname": "localhost" } ]' > endpoints.json
# Start the invoker with a chosen RPS rate and time
./invoker -port 50000 -dbg -time 10 -rps 1
```


## Running this benchmark (using knative)
### TODO: Need to test it on knative
Below contents haven't been tested on knative
The detailed and general description on how to run benchmarks on knative clusters you can find [here](../../docs/running_benchmarks.md). The following steps show it on the spright-python function.
1. Build or pull the function images using `make all-images` or `make pull`.
2. Start the function with knative
```bash
kn service apply -f ./yamls/knative/kn-parking-function-cahin-python.yaml
```
3. **Note the URL provided in the output. The part without the `http://` we'll call `$URL`. Replace any instance of `$URL` in the code below with it.**
### Invoke once
4. In a new terminal, invoke the interface function with test-client.
```bash
./test-client --addr $URL:80 --name "Example invocation of spright"
```
### Invoke multiple times
4. Run the invoker
```bash
# build the invoker binary
cd ../../tools/invoker
make invoker
# Specify the hostname through "endpoints.json"
echo '[ { "hostname": "$URL" } ]' > endpoints.json
# Start the invoker with a chosen RPS rate and time
./invoker -port 80 -dbg -time 10 -rps 1
```
1 change: 1 addition & 0 deletions benchmarks/spright-parking/docker/nginxlocal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ RUN GPG_KEYS=13C82A63B603576156E30A4EA0EA981B66B0D967 \

COPY nginx.conf /etc/nginx/nginx.conf
COPY default.conf /etc/nginx/conf.d/default.conf
COPY nginx_setup.sh ./setup/nginx_setup.sh

# COPY sprightparking.crt /etc/ssl/cert/sprightparking.crt
# COPY sprightparking.key /etc/ssl/private/sprightparking.key
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/spright-parking/docker/nginxlocal/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ server {

location /1 {
access_by_lua_block {
os.execute("/usr/bin/curl -H \"Host: detection-1.default.example.com\" http://10.5.0.2")
os.execute("/usr/bin/curl -H \"Host: search-2.default.example.com\" http://10.5.0.3")
os.execute("/usr/bin/curl -H \"Host: index-3.default.example.com\" http://10.5.0.4")
os.execute("/usr/bin/curl -H \"Host: persist-5.default.example.com\" http://10.5.0.6")
os.execute("/usr/bin/curl -H \"Host: charging-4.default.example.com\" http://10.5.0.5")
os.execute("/usr/bin/curl -H \"Host: detection-1.default.example.com\" http://detection-1:8081")
os.execute("/usr/bin/curl -H \"Host: search-2.default.example.com\" http://search-2:8082")
os.execute("/usr/bin/curl -H \"Host: index-3.default.example.com\" http://index-3:8083")
os.execute("/usr/bin/curl -H \"Host: persist-5.default.example.com\" http://persist-5:8085")
os.execute("/usr/bin/curl -H \"Host: charging-4.default.example.com\" http://charging-4:8084")
}

default_type text/html;
Expand All @@ -32,9 +32,9 @@ server {

location /2 {
access_by_lua_block {
os.execute("/usr/bin/curl -H \"Host: detection-1.default.example.com\" http://10.5.0.2")
os.execute("/usr/bin/curl -H \"Host: search-2.default.example.com\" http://10.5.0.3")
os.execute("/usr/bin/curl -H \"Host: charging-4.default.example.com\" http://10.5.0.5")
os.execute("/usr/bin/curl -H \"Host: detection-1.default.example.com\" http://detection-1:8081")
os.execute("/usr/bin/curl -H \"Host: search-2.default.example.com\" http://search-2:8082")
os.execute("/usr/bin/curl -H \"Host: charging-4.default.example.com\" http://charging-4:8084")
}

default_type text/html;
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/spright-parking/docker/parking-python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ COPY ./benchmarks/spright-parking/python/server.py ./
COPY ./benchmarks/spright-parking/python/hack.py ./

# add proto file from github
# ADD https://raw.githubusercontent.com/vhive-serverless/vSwarm-proto/v0.3.0/proto/parking/parking_pb2_grpc.py ./
# ADD https://raw.githubusercontent.com/vhive-serverless/vSwarm-proto/v0.3.0/proto/parking/parking_pb2.py ./proto/parking_pb2_grpc/
COPY ./benchmarks/spright-parking/python/parking_pb2_grpc.py ./
ADD https://raw.githubusercontent.com/vhive-serverless/vSwarm-proto/v0.5.2/proto/parking/parking_pb2_grpc.py ./
ADD https://raw.githubusercontent.com/vhive-serverless/vSwarm-proto/v0.5.2/proto/parking/parking_pb2.py ./proto/parking/
COPY ./benchmarks/spright-parking/python/image.jpeg ./
# COPY ./benchmarks/spright-parking/python/parking_pb2.py ./proto/parking_pb2_grpc/ # prob not working
COPY ./benchmarks/spright-parking/python/parking_pb2.py ./
# COPY ./benchmarks/spright-parking/python/parking_pb2.py ./



Expand Down
24 changes: 12 additions & 12 deletions benchmarks/spright-parking/python/parking_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 19 additions & 19 deletions benchmarks/spright-parking/python/parking_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

import parking_pb2 as parking__pb2
from proto.parking import parking_pb2 as proto_dot_parking_dot_parking__pb2


class GreeterStub(object):
class ParkingStub(object):
"""Missing associated documentation comment in .proto file."""

def __init__(self, channel):
Expand All @@ -14,42 +14,42 @@ def __init__(self, channel):
Args:
channel: A grpc.Channel.
"""
self.SayHello = channel.unary_unary(
'/parking.Greeter/SayHello',
request_serializer=parking__pb2.ParkingRequest.SerializeToString,
response_deserializer=parking__pb2.ParkingReply.FromString,
self.DoParking = channel.unary_unary(
'/parking.Parking/DoParking',
request_serializer=proto_dot_parking_dot_parking__pb2.ParkingRequest.SerializeToString,
response_deserializer=proto_dot_parking_dot_parking__pb2.ParkingReply.FromString,
)


class GreeterServicer(object):
class ParkingServicer(object):
"""Missing associated documentation comment in .proto file."""

def SayHello(self, request, context):
def DoParking(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_GreeterServicer_to_server(servicer, server):
def add_ParkingServicer_to_server(servicer, server):
rpc_method_handlers = {
'SayHello': grpc.unary_unary_rpc_method_handler(
servicer.SayHello,
request_deserializer=parking__pb2.ParkingRequest.FromString,
response_serializer=parking__pb2.ParkingReply.SerializeToString,
'DoParking': grpc.unary_unary_rpc_method_handler(
servicer.DoParking,
request_deserializer=proto_dot_parking_dot_parking__pb2.ParkingRequest.FromString,
response_serializer=proto_dot_parking_dot_parking__pb2.ParkingReply.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'parking.Greeter', rpc_method_handlers)
'parking.Parking', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))


# This class is part of an EXPERIMENTAL API.
class Greeter(object):
class Parking(object):
"""Missing associated documentation comment in .proto file."""

@staticmethod
def SayHello(request,
def DoParking(request,
target,
options=(),
channel_credentials=None,
Expand All @@ -59,8 +59,8 @@ def SayHello(request,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/parking.Greeter/SayHello',
parking__pb2.ParkingRequest.SerializeToString,
parking__pb2.ParkingReply.FromString,
return grpc.experimental.unary_unary(request, target, '/parking.Parking/DoParking',
proto_dot_parking_dot_parking__pb2.ParkingRequest.SerializeToString,
proto_dot_parking_dot_parking__pb2.ParkingReply.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
Loading

0 comments on commit 908c222

Please sign in to comment.