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

When aiotools num_worker set as many as cpu cores, dead with error. #17

Closed
FuZer opened this issue Mar 30, 2018 · 3 comments
Closed

When aiotools num_worker set as many as cpu cores, dead with error. #17

FuZer opened this issue Mar 30, 2018 · 3 comments
Assignees

Comments

@FuZer
Copy link

FuZer commented Mar 30, 2018

If I specify num_worker as the number of cores as mentioned in the title, an error occurs.
So I specify 20 worker. any other way to solve this?

$ grep -c processor /proc/cpuinfo
40
ERROR aiotools.server [Process-7] Worker 7: Error during initialization
Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiotools/server.py", line 56, in _worker_main
    loop.run_until_complete(ctx.__aenter__())
  File "uvloop/loop.pyx", line 1203, in uvloop.loop.Loop.run_until_complete (uvloop/loop.c:25636)
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiotools/context.py", line 78, in __aenter__
    return (await self._agen.__anext__())
  File "/home/ubuntu/backend.ai-manager/ai/backend/gateway/server.py", line 284, in server_main
    await gw_init(app)
  File "/home/ubuntu/backend.ai-manager/ai/backend/gateway/server.py", line 188, in gw_init
    timeout=30, pool_recycle=30,
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiopg/utils.py", line 70, in __await__
    resp = yield from self._coro
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiopg/sa/engine.py", line 70, in _create_engine
    pool_recycle=pool_recycle, **kwargs)
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiopg/utils.py", line 65, in __iter__
    resp = yield from self._coro
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiopg/pool.py", line 47, in _create_pool
    yield from pool._fill_free_pool(False)
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiopg/pool.py", line 209, in _fill_free_pool
    **self._conn_kwargs)
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiopg/utils.py", line 65, in __iter__
    resp = yield from self._coro
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiopg/connection.py", line 74, in _connect
    yield from conn._poll(waiter, timeout)
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiopg/connection.py", line2018-03-30 14:02:57 INFO ai.backend.gateway.server [Process-6] shutting down...
 238, in _poll
    yield from asyncio.wait_for(self._waiter, timeout, loop=self._loop)
  File "/home/ubuntu/.pyenv/versions/3.6.4/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/home/ubuntu/.pyenv/versions/venv-manager/lib/python3.6/site-packages/aiopg/connection.py", line 135, in _ready
    state = self._conn.poll()
psycopg2.OperationalError: FATAL:  sorry, too many clients already
@achimnol achimnol added the type:bug Reports about that are not working label Mar 30, 2018
@achimnol achimnol self-assigned this Mar 30, 2018
@achimnol
Copy link
Member

I'll look into it!

achimnol added a commit to lablup/backend.ai-manager that referenced this issue Apr 8, 2018
@achimnol
Copy link
Member

achimnol commented Apr 8, 2018

The number of workers in the Backend.AI gateway is not related to the performance of your Backend.AI user-code execution. It mainly affects the API (HTTP request) processing throughput.

Therefere it is safe to have low numbers for private setups where the concurrent client connections are far less than hundreds or thousands. Even a single thread setup can handle hundreds of concurrent HTTP requests without hassles. (In Backend.AI, the main performance-limiting factor is the latency of Docker APIs in the agents.)

So I'm going to add a patch so that you can customize the number of gateway processes using a CLI argument while its default is set to a small number (at most 4).

@achimnol
Copy link
Member

As there are no more responses after I have provided the patch, closing the issue.
Please reopen or open another issue if you have further problems.

@achimnol achimnol removed the type:bug Reports about that are not working label Oct 18, 2024
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