Why not publish to a redis qiueue, and then use a separate workers to do 
the writes.

redis publish is light weight and fast

T

On Sunday, November 11, 2018 at 6:25:36 AM UTC+8, Zsolt Ero wrote:
>
> On a fairly classic Pyramid app (sync, gunicorn, SQLAlchemy / Postgresql, 
> like the starter template), I am storing analytics-like events in a table 
> for some of my views.
>
> Like this skeleton:
>
> @view_config(route_name='test', request_method='POST', renderer='json')
> def test(request):
>     # body of the view
>     map_id = request.json_body.get('map_id')
>     data = {...}
>     
>     event_data = {'action': 'viewed'}
>     event = MapEvent(user=request.user, action=event_data, map_id=map_id)
>     request.dbsession.add(event)
>
>     return data
>
>
>
> My problem is that while 99% of the views make read-only requests to the 
> database, and thus are very fast, the analytics event is a writing and can 
> be slow occasionally. 
>
> Would it be possible to somehow send the request to the client and still 
> keep processing the view? Like a send() + end() method or something 
> similar, without returning?
>
> // Adding to a tasks queue is not an option as it'd be an overkill and an 
> overcomplicated solution, which wouldn't work for hundreds of thousands of 
> events per day. 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/bd6f6169-92dc-47c4-933f-60eb801a1c3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to