Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaying access pattern #411

Closed
bicatu opened this issue May 5, 2016 · 2 comments
Closed

Replaying access pattern #411

bicatu opened this issue May 5, 2016 · 2 comments

Comments

@bicatu
Copy link

bicatu commented May 5, 2016

I am doing a new version of an existing system and I'd like to put it under the same "stress" level that the current one has.

I grabbed from the access logs a 10 minutes sample of the access and since both systems accept the exact parameters/url I was considering using locust to do it.

I have stats so, for example, Url A receives on average X requests/sec, Url B receives Y requests/sec.

The questions are :

  • is locust the tool to do it
  • based on the docs I could not figure it out how to do such a thing
@bicatu
Copy link
Author

bicatu commented May 10, 2016

No comments?

@justiniso
Copy link
Member

If you are trying to replay access logs to test your application, yes this is possible with locust and a wide range of other tools. However, I recommend using the same tool to test application of both versions so you're comparing apples to apples. With locust, you might try something like this:

import re

from locust import HttpLocust, TaskSet, task

# Read your access log and extract the path from each line; use this list
# of paths to request each url
path_pattern = re.compile('REGEX_TO_MATCH_PATH')
with open('access.log') as f:
    lines = f.read().split('\n')

urls = []
for line in lines:
    urls.append(path_pattern.match(line).group(1))

class Tasks(TaskSet):
    @task
    def replay(self):
        self.client.get(urls.pop())
    
class Locust(HttpLocust):
    min_wait = 0
    max_wait = 0
    task_set = UserTasks
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants