Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pump, Cedric
lab-grpc
Commits
9213e04b
Commit
9213e04b
authored
Apr 11, 2021
by
CedricPump
Browse files
- deploy trigger
parent
2ee42020
Pipeline
#39109
passed with stages
in 58 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
9213e04b
grpc/helloworld_pb2_grpc.py
grpc/helloworld_pb2.py
grpc/.idea/.gitignore
grpc/.idea/
grpc/venv/
rest/.idea/.gitignore
rest/.idea/
rest/venv/
grpc/__pycache__/helloworld_pb2.cpython-36.pyc
0 → 100644
View file @
9213e04b
File added
grpc/__pycache__/helloworld_pb2_grpc.cpython-36.pyc
0 → 100644
View file @
9213e04b
File added
grpc/compare.py
0 → 100644
View file @
9213e04b
import
requests
,
time
,
os
from
statistics
import
median
import
grpc
import
helloworld_pb2
import
helloworld_pb2_grpc
grpc_svc
=
os
.
environ
.
get
(
"GRPC_SVC"
,
"localhost"
)
grpc_port
=
os
.
environ
.
get
(
"GRPC_PORT"
,
"5555"
)
rest_svc
=
os
.
environ
.
get
(
"REST_SVC"
,
"localhost"
)
rest_port
=
os
.
environ
.
get
(
"REST_PORT"
,
"5000"
)
channel
=
grpc
.
insecure_channel
(
f
"
{
grpc_svc
}
:
{
grpc_port
}
"
)
stub
=
helloworld_pb2_grpc
.
GreeterStub
(
channel
)
grpc_s
=
[]
rest_s
=
[]
while
True
:
for
i
in
range
(
0
,
100
):
start
=
time
.
time
()
response
=
stub
.
SayHello
(
helloworld_pb2
.
HelloRequest
(
name
=
'you'
))
grpc_s
.
append
(
time
.
time
()
-
start
)
start
=
time
.
time
()
x
=
requests
.
get
(
f
"http://
{
rest_svc
}
:
{
rest_port
}
/hello/you"
)
rest_s
.
append
(
time
.
time
()
-
start
)
print
(
f
"gRPC:
{
median
(
grpc_s
)
*
1000
:
05.2
f
}
ms REST:
{
median
(
rest_s
)
*
1000
:
05.2
f
}
ms"
)
rest/api.py
0 → 100644
View file @
9213e04b
import
flask
app
=
flask
.
Flask
(
__name__
)
app
.
config
[
"DEBUG"
]
=
True
@
app
.
route
(
'/'
,
methods
=
[
'GET'
])
def
hello
():
return
'Hello!'
@
app
.
route
(
'/hello/<name>'
,
methods
=
[
'GET'
])
def
helloName
(
name
):
return
'Hello, '
+
name
@
app
.
errorhandler
(
404
)
def
page_not_found
(
e
):
return
"<h1>404</h1><p>The resource could not be found.</p>"
,
404
app
.
run
(
host
=
"0.0.0.0"
)
\ No newline at end of file
result.txt
0 → 100644
View file @
9213e04b
Test Local:
gRPC: 01.00ms REST: 2006.00ms
Test Cluster:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment