This patch rate-limit the requests by adding a delay using the
`ajax.delay` option provided by Select2.
--
Ticket URL: <https://code.djangoproject.com/ticket/30722>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "no-rate-limit.mp4" added.
Multiple consecutive request
* Attachment "with-rate-limit.mp4" added.
Requests with a delay until user stops typing
* has_patch: 0 => 1
* type: Uncategorized => Cleanup/optimization
Old description:
> The current implementation of the Ajax autocomplete widget using Select2
> in Django triggers a request for every key-press. This creates
> unnecessary load on servers.
>
> This patch rate-limit the requests by adding a delay using the
> `ajax.delay` option provided by Select2.
New description:
The current implementation of the Ajax autocomplete widget using Select2
in Django triggers a request for every key-press. This creates unnecessary
load on servers.
This patch rate-limit the requests by adding a delay using the
`ajax.delay` option provided by Select2.
https://github.com/django/django/pull/11695
--
Comment:
Include link to PR
--
Ticket URL: <https://code.djangoproject.com/ticket/30722#comment:1>
* stage: Unreviewed => Accepted
Comment:
I cannot say for sure 500 is the good value, but some delay is definitely
an improvement.
--
Ticket URL: <https://code.djangoproject.com/ticket/30722#comment:2>
* status: new => assigned
* needs_better_patch: 0 => 1
* owner: nobody => Federico Jaramillo Martínez
--
Ticket URL: <https://code.djangoproject.com/ticket/30722#comment:3>
* needs_better_patch: 1 => 0
Comment:
Updated the patch, tests are passing.
500 was the number that gave me the least amount of unnecessary requests
while still giving a perception of responsiveness, but those were more or
less empiric tests with some co-workers. More than 500 **felt** slow.
We found that less than 250 would start sending requests for slow typers.
Given that this would be a default, I proposed 500 as that was the higher
acceptable number for us. If a specific site requires a lower delay, it
can be overridden on a custom widget or by overriding
`resources/static/admin/js/autocomplete.js`.
I thought that it would be more important to avoid unnecessary requests
over the gain of 100ms in the admin area.
--
Ticket URL: <https://code.djangoproject.com/ticket/30722#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"8f6860863e34cb1cbe24161f1c4e7c79007e93dc" 8f686086]:
{{{
#!CommitTicketReference repository=""
revision="8f6860863e34cb1cbe24161f1c4e7c79007e93dc"
Fixed #30722 -- Added default rate-limiting requests to admin's Select2
widget.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30722#comment:5>