diff --git a/benchmarks/gg/benchmarks/llvm/llvm.tar.gz b/benchmarks/gg/benchmarks/llvm/llvm.tar.gz deleted file mode 100755 index 4935e6ea..00000000 --- a/benchmarks/gg/benchmarks/llvm/llvm.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cc7b5697b2784f58de268a1d10120af33eaa229a105cd9bff6c3dc0d26f7b233 -size 317913690 diff --git a/benchmarks/spright-parking/Makefile b/benchmarks/spright-parking/Makefile index b67f0811..0cab0eda 100644 --- a/benchmarks/spright-parking/Makefile +++ b/benchmarks/spright-parking/Makefile @@ -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 diff --git a/benchmarks/spright-parking/README.md b/benchmarks/spright-parking/README.md new file mode 100644 index 00000000..57fc4848 --- /dev/null +++ b/benchmarks/spright-parking/README.md @@ -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 + ``` diff --git a/benchmarks/spright-parking/docker/nginxlocal/Dockerfile b/benchmarks/spright-parking/docker/nginxlocal/Dockerfile index 644cf949..981bfe33 100644 --- a/benchmarks/spright-parking/docker/nginxlocal/Dockerfile +++ b/benchmarks/spright-parking/docker/nginxlocal/Dockerfile @@ -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 diff --git a/benchmarks/spright-parking/docker/nginxlocal/default.conf b/benchmarks/spright-parking/docker/nginxlocal/default.conf index 14a19cd9..483591da 100644 --- a/benchmarks/spright-parking/docker/nginxlocal/default.conf +++ b/benchmarks/spright-parking/docker/nginxlocal/default.conf @@ -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; @@ -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; diff --git a/benchmarks/spright-parking/yaml/docker-compose/nginx_setup.sh b/benchmarks/spright-parking/docker/nginxlocal/nginx_setup.sh similarity index 100% rename from benchmarks/spright-parking/yaml/docker-compose/nginx_setup.sh rename to benchmarks/spright-parking/docker/nginxlocal/nginx_setup.sh diff --git a/benchmarks/spright-parking/docker/parking-python/Dockerfile b/benchmarks/spright-parking/docker/parking-python/Dockerfile index d10b2dcb..cab414bc 100644 --- a/benchmarks/spright-parking/docker/parking-python/Dockerfile +++ b/benchmarks/spright-parking/docker/parking-python/Dockerfile @@ -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 ./ diff --git a/benchmarks/spright-parking/python/parking_pb2.py b/benchmarks/spright-parking/python/parking_pb2.py index e8cc864a..5705f74b 100644 --- a/benchmarks/spright-parking/python/parking_pb2.py +++ b/benchmarks/spright-parking/python/parking_pb2.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! -# source: parking.proto -# Protobuf Python Version: 4.25.2 +# source: proto/parking/parking.proto """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool @@ -14,18 +13,19 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\rparking.proto\x12\x07parking\"\x1e\n\x0eParkingRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1e\n\x0cParkingReply\x12\x0e\n\x06result\x18\x01 \x01(\t2G\n\x07Greeter\x12<\n\x08SayHello\x12\x17.parking.ParkingRequest\x1a\x15.parking.ParkingReply\"\x00\x42\x38Z6github.com/vhive-serverless/vSwarm-proto/proto/parkingb\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bproto/parking/parking.proto\x12\x07parking\"\x1e\n\x0eParkingRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1e\n\x0cParkingReply\x12\x0e\n\x06result\x18\x01 \x01(\t2H\n\x07Parking\x12=\n\tDoParking\x12\x17.parking.ParkingRequest\x1a\x15.parking.ParkingReply\"\x00\x42\x38Z6github.com/vhive-serverless/vSwarm-proto/proto/parkingb\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'parking_pb2', _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'proto.parking.parking_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - _globals['DESCRIPTOR']._options = None - _globals['DESCRIPTOR']._serialized_options = b'Z6github.com/vhive-serverless/vSwarm-proto/proto/parking' - _globals['_PARKINGREQUEST']._serialized_start=26 - _globals['_PARKINGREQUEST']._serialized_end=56 - _globals['_PARKINGREPLY']._serialized_start=58 - _globals['_PARKINGREPLY']._serialized_end=88 - _globals['_GREETER']._serialized_start=90 - _globals['_GREETER']._serialized_end=161 + + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'Z6github.com/vhive-serverless/vSwarm-proto/proto/parking' + _globals['_PARKINGREQUEST']._serialized_start=40 + _globals['_PARKINGREQUEST']._serialized_end=70 + _globals['_PARKINGREPLY']._serialized_start=72 + _globals['_PARKINGREPLY']._serialized_end=102 + _globals['_PARKING']._serialized_start=104 + _globals['_PARKING']._serialized_end=176 # @@protoc_insertion_point(module_scope) diff --git a/benchmarks/spright-parking/python/parking_pb2_grpc.py b/benchmarks/spright-parking/python/parking_pb2_grpc.py index b7c2b7ad..7a41f08c 100644 --- a/benchmarks/spright-parking/python/parking_pb2_grpc.py +++ b/benchmarks/spright-parking/python/parking_pb2_grpc.py @@ -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): @@ -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, @@ -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) diff --git a/benchmarks/spright-parking/python/proto/parking/parking.pb.go b/benchmarks/spright-parking/python/proto/parking/parking.pb.go deleted file mode 100644 index 91f0388d..00000000 --- a/benchmarks/spright-parking/python/proto/parking/parking.pb.go +++ /dev/null @@ -1,214 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.32.0 -// protoc v4.25.2 -// source: parking.proto - -package parking - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ParkingRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *ParkingRequest) Reset() { - *x = ParkingRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_parking_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParkingRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParkingRequest) ProtoMessage() {} - -func (x *ParkingRequest) ProtoReflect() protoreflect.Message { - mi := &file_parking_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParkingRequest.ProtoReflect.Descriptor instead. -func (*ParkingRequest) Descriptor() ([]byte, []int) { - return file_parking_proto_rawDescGZIP(), []int{0} -} - -func (x *ParkingRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -type ParkingReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` -} - -func (x *ParkingReply) Reset() { - *x = ParkingReply{} - if protoimpl.UnsafeEnabled { - mi := &file_parking_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ParkingReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ParkingReply) ProtoMessage() {} - -func (x *ParkingReply) ProtoReflect() protoreflect.Message { - mi := &file_parking_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ParkingReply.ProtoReflect.Descriptor instead. -func (*ParkingReply) Descriptor() ([]byte, []int) { - return file_parking_proto_rawDescGZIP(), []int{1} -} - -func (x *ParkingReply) GetResult() string { - if x != nil { - return x.Result - } - return "" -} - -var File_parking_proto protoreflect.FileDescriptor - -var file_parking_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x70, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x07, 0x70, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x22, 0x24, 0x0a, 0x0e, 0x50, 0x61, 0x72, 0x6b, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x26, - 0x0a, 0x0c, 0x50, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x16, - 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0x47, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, - 0x72, 0x12, 0x3c, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x17, 0x2e, - 0x70, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x2e, 0x50, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x67, - 0x2e, 0x50, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, - 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x68, - 0x69, 0x76, 0x65, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x6c, 0x65, 0x73, 0x73, 0x2f, 0x76, - 0x53, 0x77, 0x61, 0x72, 0x6d, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x70, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var ( - file_parking_proto_rawDescOnce sync.Once - file_parking_proto_rawDescData = file_parking_proto_rawDesc -) - -func file_parking_proto_rawDescGZIP() []byte { - file_parking_proto_rawDescOnce.Do(func() { - file_parking_proto_rawDescData = protoimpl.X.CompressGZIP(file_parking_proto_rawDescData) - }) - return file_parking_proto_rawDescData -} - -var file_parking_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_parking_proto_goTypes = []interface{}{ - (*ParkingRequest)(nil), // 0: parking.ParkingRequest - (*ParkingReply)(nil), // 1: parking.ParkingReply -} -var file_parking_proto_depIdxs = []int32{ - 0, // 0: parking.Greeter.SayHello:input_type -> parking.ParkingRequest - 1, // 1: parking.Greeter.SayHello:output_type -> parking.ParkingReply - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_parking_proto_init() } -func file_parking_proto_init() { - if File_parking_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_parking_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParkingRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_parking_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ParkingReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_parking_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_parking_proto_goTypes, - DependencyIndexes: file_parking_proto_depIdxs, - MessageInfos: file_parking_proto_msgTypes, - }.Build() - File_parking_proto = out.File - file_parking_proto_rawDesc = nil - file_parking_proto_goTypes = nil - file_parking_proto_depIdxs = nil -} diff --git a/benchmarks/spright-parking/python/proto/parking/parking.proto b/benchmarks/spright-parking/python/proto/parking/parking.proto deleted file mode 100644 index 62eddf97..00000000 --- a/benchmarks/spright-parking/python/proto/parking/parking.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; - -option go_package = "github.com/vhive-serverless/vSwarm-proto/proto/parking"; - -package parking; - -service Greeter { - rpc SayHello(ParkingRequest) returns (ParkingReply) {} -} - -message ParkingRequest { - string name = 1; -} - -message ParkingReply { - string result = 1; -} diff --git a/benchmarks/spright-parking/python/proto/parking/parking_grpc.pb.go b/benchmarks/spright-parking/python/proto/parking/parking_grpc.pb.go deleted file mode 100644 index d6f15fcc..00000000 --- a/benchmarks/spright-parking/python/proto/parking/parking_grpc.pb.go +++ /dev/null @@ -1,109 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v4.25.2 -// source: parking.proto - -package parking - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - Greeter_SayHello_FullMethodName = "/parking.Greeter/SayHello" -) - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GreeterClient interface { - SayHello(ctx context.Context, in *ParkingRequest, opts ...grpc.CallOption) (*ParkingReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *ParkingRequest, opts ...grpc.CallOption) (*ParkingReply, error) { - out := new(ParkingReply) - err := c.cc.Invoke(ctx, Greeter_SayHello_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer -// for forward compatibility -type GreeterServer interface { - SayHello(context.Context, *ParkingRequest) (*ParkingReply, error) - mustEmbedUnimplementedGreeterServer() -} - -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (UnimplementedGreeterServer) SayHello(context.Context, *ParkingRequest) (*ParkingReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} - -// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GreeterServer will -// result in compilation errors. -type UnsafeGreeterServer interface { - mustEmbedUnimplementedGreeterServer() -} - -func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { - s.RegisterService(&Greeter_ServiceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ParkingRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Greeter_SayHello_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*ParkingRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Greeter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "parking.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "parking.proto", -} diff --git a/benchmarks/spright-parking/python/server.py b/benchmarks/spright-parking/python/server.py index 2b0d10f5..237c7c5d 100644 --- a/benchmarks/spright-parking/python/server.py +++ b/benchmarks/spright-parking/python/server.py @@ -4,108 +4,97 @@ import threading import requests, time, random # protobuf -import parking_pb2 +import proto.parking.parking_pb2 as parking_pb2 import parking_pb2_grpc import grpc +import logging from concurrent import futures +import sys -global stat_file +logging.basicConfig(stream=sys.stdout, level=logging.INFO) +logger = logging.getLogger(__name__) -def get_args(): - parser = argparse.ArgumentParser() - parser.add_argument('-i', '--nginxip', action='store', type=str, default='127.0.0.1') - parser.add_argument('-p', '--nginxport', action='store', type=str, default='80') - parser.add_argument('-I', '--istioip', action='store', type=str, default='127.0.0.1') - parser.add_argument('-P', '--istioport', action='store', type=str, default='80') - args = parser.parse_args() - return args def post(http_url, send_time): - print("http_url: ", http_url) - print("Send a request at {}".format(send_time)) # DEBUG + logger.info("http_url: ", http_url) + logger.info("Send a request at {}".format(send_time)) # DEBUG files = {'file': open('image.jpeg', 'rb')} tmp_url = '' + function_chain = '' if random.random() < 0.9: tmp_url = http_url + '2/' + function_chain = f"[detection, search, charging]" + else: tmp_url = http_url + '1/' + function_chain = f"[detection, search, index, persist, charging]" r = requests.post(url = tmp_url, files=files) - # DEBUG - body_len = len(r.request.body if r.request.body else []) - print(body_len) - print(str(time.time()) + ";" + str(r.elapsed.total_seconds())) - - lock.acquire() - stat_file.write(str(time.time()) + ";" + str(r.elapsed.total_seconds()) + "\n") - lock.release() - -def warm_up(fname): - h = fname + '.default.example.com' - print("Wake up " + h) - r = requests.get(url = INGRESS_URL, headers = {"Host": h}) - print("Cold start + Processing delay = " + str(r.elapsed.total_seconds())) - -def do_parking_call(): - stat_file = open('kn.parking_output.csv', 'w') - - args = get_args() - URL = "http://" + args.nginxip + ":" + args.nginxport + "/" - - lock=threading.Lock() + result = '' + if r.status_code != 200: + result = f"Invoke function chain: {function_chain} fail!" + else: + + result = f"Invoke function chain {function_chain} success!" + return result - functions = ['detection-1', 'search-2', 'index-3', 'charging-4', 'persist-5'] - threads = [] - # for x in threads: - # x.join() +def do_parking_call(nginx_ip, nginx_port): + + url = f"http://{nginx_ip}:{nginx_port}/" - max_run_time_sec = 600 total_sec = 0 - st_1 = 220 - st_2 = 20 try: - while(1): - print("Send snapshots at {}".format(total_sec)) - # Send request to function chain - for i in range(0, 164): - th = threading.Thread(target=post, args=(URL, total_sec)) - th.daemon = True - th.start() - time.sleep(st_1) - print("Sleep for {}".format(st)) - total_sec = total_sec + st_1 - if total_sec >= max_run_time_sec: - break + logger.info("Send snapshots at {}".format(total_sec)) + # Send request to function chain + response = post(url, total_sec) + return response + except KeyboardInterrupt: - stat_file.close() exit(1) - stat_file.close() -class Parking(parking_pb2_grpc.GreeterServicer): - def SayHello(self, request, context): - if request.plaintext_message in ["", "world"]: - plaintext = args.default_plaintext - print(plaintext) - do_parking_call() - else: - plaintext = request.plaintext_message - print("else: ", plaintext) - - return parking_pb2.parkingReply(result="reply") - -def serve(): +class Parking(parking_pb2_grpc.ParkingServicer): + def __init__(self, + nginx_ip, + nginx_port) -> None: + super().__init__() + self.nginx_ip = nginx_ip + self.nginx_port = nginx_port + + def DoParking(self, request, context): + logger.info(f"Receive request from relay, call do_parking") + result = do_parking_call(nginx_ip, nginx_port) + + return parking_pb2.ParkingReply(result=result) + +def serve(addr, port, nginx_ip, nginx_port): server = grpc.server(futures.ThreadPoolExecutor(max_workers=1)) - parking_pb2_grpc.add_GreeterServicer_to_server(Parking(), server) + parking_pb2_grpc.add_ParkingServicer_to_server(Parking(nginx_ip, nginx_port), server) - # address = (args.addr + ":" + args.port) # TODO - address = ("0.0.0.0:50051") + address = f"{addr}:{port}" server.add_insecure_port(address) - print("Start Parking-python server. Addr: " + address) + logger.info("Start Parking-python server. Addr: " + address) server.start() - print("Parking-python server started and listening on " + address) + logger.info("Parking-python server started and listening on " + address) server.wait_for_termination() -if __name__ == '__main__': - serve() \ No newline at end of file +if __name__ == "__main__": + # Initialize the parser + parser = argparse.ArgumentParser(description='python server that invokes spright-parking') + + # Add arguments + parser.add_argument('--addr', type=str, help='Address to listen on', default='0.0.0.0') + parser.add_argument('--port', type=int, help='Port to listen on', default=50051) + parser.add_argument('--nginxip', type=str, help='Nginx IP address', default='parking-proxy') + parser.add_argument('--ngixport', type=int, help='Nginx port', default=80) + + # Parse the arguments + args = parser.parse_args() + + # Access the parsed arguments + addr = args.addr + port = args.port + nginx_ip = args.nginxip + nginx_port = args.ngixport + serve(addr, port, nginx_ip, nginx_port) \ No newline at end of file diff --git a/benchmarks/spright-parking/yaml/docker-compose/dc-parking.yaml b/benchmarks/spright-parking/yamls/docker-compose/dc-parking.yaml similarity index 56% rename from benchmarks/spright-parking/yaml/docker-compose/dc-parking.yaml rename to benchmarks/spright-parking/yamls/docker-compose/dc-parking.yaml index 446a6b5f..fab2c5f6 100644 --- a/benchmarks/spright-parking/yaml/docker-compose/dc-parking.yaml +++ b/benchmarks/spright-parking/yamls/docker-compose/dc-parking.yaml @@ -1,21 +1,5 @@ version: '3' services: - relay: - image: vhiveease/relay:latest - platform: linux/arm64 - entrypoint: - - /app/server - - --addr=0.0.0.0:50000 - - --function-endpoint-url=parking-python - - --function-endpoint-port=50051 - - --function-name=parking-python - ports: - - published: 50000 - target: 50000 - networks: - vpcbr: - ipv4_address: 10.5.0.7 - parking-python-server: image: vhiveease/parking-python:latest container_name: parking-python @@ -24,59 +8,51 @@ services: - /app/server.py - --addr=0.0.0.0 - --port=50051 + - --nginxip=parking-proxy + - --ngixport=80 ports: - target: 50051 - networks: - vpcbr: - ipv4_address: 10.5.0.8 detection-1: image: docker.io/shixiongqi/kn-dummy - # ports: - # - "50001:50001" + ports: + - "8081:8080" container_name: detection-1 environment: - SLEEP_TIME=453000 - networks: - vpcbr: - ipv4_address: 10.5.0.2 - search-2: + search-2: image: docker.io/shixiongqi/kn-dummy container_name: search-2 + ports: + - "8082:8080" environment: - SLEEP_TIME=20000 - networks: - vpcbr: - ipv4_address: 10.5.0.3 index-3: image: docker.io/shixiongqi/kn-dummy container_name: index-3 + ports: + - "8083:8080" environment: - SLEEP_TIME=1000 - networks: - vpcbr: - ipv4_address: 10.5.0.4 charging-4: image: docker.io/shixiongqi/kn-dummy container_name: charging-4 + ports: + - "8084:8080" environment: - SLEEP_TIME=50000 - networks: - vpcbr: - ipv4_address: 10.5.0.5 persist-5: image: docker.io/shixiongqi/kn-dummy container_name: persist-5 + ports: + - "8085:8080" environment: - SLEEP_TIME=10000 - networks: - vpcbr: - ipv4_address: 10.5.0.6 parking-proxy: container_name: webserver @@ -86,17 +62,17 @@ services: ports: - "80:80" - "443:443" - # entrypoint: ["/bin/sh", "-c", "./setup/nginx_setup.sh"] - # command: /bin/sh -c "chmod +x /setup/nginx_setup.sh && setup/nginx_setup.sh" - # command: ["/bin/sh", "-c", "apk add --no-cache curl && nginx -g 'daemon off;'"] - networks: - vpcbr: - ipv4_address: 10.5.0.9 + entrypoint: ["/bin/sh", "-c", "./setup/nginx_setup.sh"] -networks: - vpcbr: - driver: bridge - ipam: - config: - - subnet: 10.5.0.0/16 - gateway: 10.5.0.1 + relay: + image: vhiveease/relay:latest + platform: linux/amd64 + entrypoint: + - /app/server + - --addr=0.0.0.0:50000 + - --function-endpoint-url=parking-python-server + - --function-endpoint-port=50051 + - --function-name=spright-parking-python + ports: + - published: 50000 + target: 50000 diff --git a/benchmarks/spright-parking/yaml/knative/kn-parking-function-chain.yaml b/benchmarks/spright-parking/yamls/knative/kn-parking-function-chain.yaml similarity index 100% rename from benchmarks/spright-parking/yaml/knative/kn-parking-function-chain.yaml rename to benchmarks/spright-parking/yamls/knative/kn-parking-function-chain.yaml diff --git a/benchmarks/spright-parking/yaml/knative/kn-parking-proxy.yaml b/benchmarks/spright-parking/yamls/knative/kn-parking-proxy.yaml similarity index 100% rename from benchmarks/spright-parking/yaml/knative/kn-parking-proxy.yaml rename to benchmarks/spright-parking/yamls/knative/kn-parking-proxy.yaml diff --git a/tools/relay/go.mod b/tools/relay/go.mod index 0806d316..e6baab19 100644 --- a/tools/relay/go.mod +++ b/tools/relay/go.mod @@ -6,7 +6,7 @@ replace github.com/vhive-serverless/vSwarm/utils/tracing/go => ../../utils/traci require ( github.com/sirupsen/logrus v1.9.3 - github.com/vhive-serverless/vSwarm-proto v0.5.0 + github.com/vhive-serverless/vSwarm-proto v0.5.2 github.com/vhive-serverless/vSwarm/utils/tracing/go v0.0.0-20240422181019-5b1711d87c5d google.golang.org/grpc v1.63.2 ) diff --git a/tools/relay/go.sum b/tools/relay/go.sum index ed8e301d..adc59bb3 100644 --- a/tools/relay/go.sum +++ b/tools/relay/go.sum @@ -20,8 +20,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/vhive-serverless/vSwarm-proto v0.5.0 h1:EWPD0xTs1XkBerTQVsQ9sFJSOyCUKOu7Y3L9AftuLow= -github.com/vhive-serverless/vSwarm-proto v0.5.0/go.mod h1:bUm7QUFkBnFNVhbG7PHWRNT5tXRFXR9WEkfIGE82o+0= +github.com/vhive-serverless/vSwarm-proto v0.5.2 h1:PlGF53h7chTKMY3F1P8TEAAeaUc6FxKf56ykDfSJGpk= +github.com/vhive-serverless/vSwarm-proto v0.5.2/go.mod h1:mqNOaNPkghDe3Fszx1KIvkTmwaU9y+n+YlOQVMLQ0L8= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.50.0 h1:zvpPXY7RfYAGSdYQLjp6zxdJNSYD/+FFoCTQN9IPxBs= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.50.0/go.mod h1:BMn8NB1vsxTljvuorms2hyOs8IBuuBEq0pl7ltOfy30= go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k= diff --git a/tools/relay/server b/tools/relay/server index 05a1c646..7fbe9ec8 100755 Binary files a/tools/relay/server and b/tools/relay/server differ