[DOCS] make an explicit warning not to create clients for each request (#324)
Co-authored-by: Steven Silvester <steve.silvester@mongodb.com>
This commit is contained in:
parent
e2e967b610
commit
e036c6382d
@ -18,3 +18,4 @@ The following is a list of people who have contributed to
|
||||
- Steven Silvester
|
||||
- Julius Park
|
||||
- Doeke Buursma
|
||||
- Scott Luu
|
||||
|
||||
@ -454,11 +454,10 @@ to an :class:`aiohttp.web.Application`:
|
||||
:start-after: main-start
|
||||
:end-before: main-end
|
||||
|
||||
Note that it is a common mistake to create a new client object for every
|
||||
request; this comes at a dire performance cost. Create the client
|
||||
when your application starts and reuse that one client for the lifetime
|
||||
of the process. You can maintain the client by storing a database handle
|
||||
from the client on your application object, as shown in this example.
|
||||
.. warning::
|
||||
It is a common mistake to create a new client object for every request; this comes at a dire performance cost.
|
||||
Create the client when your application starts and reuse that one client for the lifetime of the process.
|
||||
You can maintain the client by storing a database handle from the client on your application object, as shown in this example.
|
||||
|
||||
Visit ``localhost:8080/pages/page-one`` and the server responds "Hello!".
|
||||
At ``localhost:8080/pages/page-two`` it responds "Goodbye." At other URLs it
|
||||
|
||||
@ -152,10 +152,11 @@ makes it available to request handlers::
|
||||
def get(self):
|
||||
db = self.settings['db']
|
||||
|
||||
It is a common mistake to create a new client object for every
|
||||
request; **this comes at a dire performance cost**. Create the client
|
||||
when your application starts and reuse that one client for the lifetime
|
||||
of the process, as shown in these examples.
|
||||
.. warning::
|
||||
It is a common mistake to create a new client object for every
|
||||
request; **this comes at a dire performance cost**. Create the client
|
||||
when your application starts and reuse that one client for the lifetime
|
||||
of the process, as shown in these examples.
|
||||
|
||||
The Tornado :class:`~tornado.httpserver.HTTPServer` class's :meth:`start`
|
||||
method is a simple way to fork multiple web servers and use all of your
|
||||
|
||||
Loading…
Reference in New Issue
Block a user