Errors при работе с Locust

Introduction

В этой статье вы узнаете о популярных проблемах с Locust и их решении

Подразумевается, что вы работаете в Ubuntu Linux

У меня прописаны алиасы python - python3 и pip - pip3, поэтому я не пишу тройку в конце. Статья про это называется «Bash Python alias»

↓ Contents ↓
System open file limit '1024' is below minimum setting
locust: error: unrecognized arguments: --no-web
NameError: name 'between' is not defined
libuv only supports millisecond timer resolution

System open file limit '1024' is below minimum setting

Вы выполняете команду

locust

И получаете следующее предупреждение

[2020-10-27 10:36:12,176] andrei-ubuntu/WARNING/locust.main: System open file limit '1024' is below minimum setting '10000'. It's not high enough for load testing, and the OS didn't allow locust to increase it by itself. See https://github.com/locustio/locust/wiki/Installation#increasing-maximum-number-of-open-files-limit for more info.

[2020-10-27 10:36:12,177] andrei-ubuntu/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces) [2020-10-27 10:36:12,194] andrei-ubuntu/INFO/locust.main: Starting Locust 1.3.1

Минимальное количество одновременно открытых файлов должно быть от 10 000. Иначе locust не может нормально работать

Проверить предел для вашей Linux можно командой

cat /proc/sys/fs/file-max

9223372036854775807

9223372036854775807 - это мой абсолютный потолок. Но нас интересуюте ограничения для сторонних программ

Изучить лимиты можно командой ulimit флаги -Hn для жёсткого лимита и -Sn для мягкого setrlimit

ulimit -Sn

1024

1024 это как раз то значение, на которое жаловалася locust

Поднимем лимит

ulimit -Sn 10001

ulimit -Sn

10001

locust

[2020-10-27 11:33:44,124] andrei-ubuntu/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces) [2020-10-27 11:33:44,133] andrei-ubuntu/INFO/locust.main: Starting Locust 1.3.1

locust: error: unrecognized arguments: --no-web

Вы пытаетесь запусть тест без UI и выполняете команду

locust -f locustfile.py --host=https://my-site.com --no-web -u 100 -r 10

И получаете следующее предупреждение

locust: error: unrecognized arguments: --no-web

Нужно заменить --no-web на --headless потому что так решили разработчики Locust

NameError: name 'between' is not defined

Вы пытаетесь задать wait_time

NameError: name 'between' is not defined

Значит скорее всего вы просто забыли подключить between

Добавьте

from locust import between

libuv only supports millisecond timer resolution

Вы пытаетесь запусть тест используя between и получаете

c:\users\andrei\pycharmprojects\locust_demo\lib\site-packages\gevent\hub.py:158: UserWarning: libuv only supports millisecond timer resolution; all times less will be set to 1 ms with loop.timer(seconds, ref=ref) as t:

Скорее всего вы поставили минимальное значение в 0, например wait_time = between(0, 0.4)

Поставьте ненулевое значение, например 0.01

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: