Created
June 19, 2018 02:14
-
-
Save DaisukeMiyamoto/d55ef0fe3816f93e7a02d486ae8e2948 to your computer and use it in GitHub Desktop.
benchmark for AWS Kinesis Data Stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import time | |
import datetime | |
import boto3 | |
from locust import HttpLocust, TaskSet, task | |
from locust.events import request_success | |
class UserBehavior(TaskSet): | |
@task | |
def index(self): | |
self.client.get('/') | |
class Kinesis(TaskSet): | |
def on_start(self): | |
self.kinesis_client = boto3.client('kinesis', region_name='us-west-2') | |
@task | |
def put(self): | |
stream_name = 'my-stream' | |
start_at = time.time() | |
response = self.kinesis_client.put_record( | |
StreamName=stream_name, | |
Data='hogehoge\n', | |
PartitionKey='1' | |
) | |
request_success.fire( | |
request_type='PUT', | |
name=stream_name, | |
response_time=int((time.time() - start_at) * 1000), | |
response_length=len(response) | |
) | |
class WebsiteUser(HttpLocust): | |
# task_set = UserBehavior | |
task_set = Kinesis | |
min_wait = 0 | |
max_wait = 10 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment