TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Write Fast Apps Using Async Python 3.6 and Redis

337 pointsby midasabout 8 years ago

16 comments

zzzeekabout 8 years ago
&gt; we make heavy use of asyncio because it’s more performant<p>more performant than....what exactly? If I need to load 1000 rows from a database and splash them on a webpage, will my response time go from the 300ms it takes without asyncio to something &quot;more performant&quot;, like 50ms? Answer: no. async only gives you throughput, it has nothing to do with &quot;faster&quot; as far as the Python interpreter &#x2F; GIL &#x2F; anything like that. If you aren&#x27;t actually spanning among dozens&#x2F;hundreds&#x2F;thousands of network connections, non-blocking IO isn&#x27;t buying you much at all over using blocking IO with threads, and of course async &#x2F; greenlets &#x2F; threads are not a prerequisite for non-blocking IO in any case (only select() is).<p>it&#x27;s nice that uvloop seems to be working on removing the terrible performance latency that out-of-the-box asyncio adds, so that&#x27;s a reason that asyncio can really be viable as a means of gaining throughput without adding lots of latency you wouldn&#x27;t get with gevent. But I can do without the enforced async boilerplate. Thanks javascript!
评论 #14215943 未加载
评论 #14214416 未加载
评论 #14215202 未加载
评论 #14216602 未加载
评论 #14216123 未加载
评论 #14216030 未加载
评论 #14216357 未加载
评论 #14218262 未加载
评论 #14216281 未加载
评论 #14218100 未加载
erikcwabout 8 years ago
We&#x27;ve just recently started using Sanic[0] paired with Redis to great effect for a very high throughput web service. It also uses Python 3 asyncio&#x2F;uvloop at its core. So far very happy with it.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;channelcat&#x2F;sanic" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;channelcat&#x2F;sanic</a>
评论 #14213786 未加载
评论 #14214122 未加载
评论 #14222066 未加载
评论 #14215071 未加载
评论 #14214067 未加载
mixmastamykabout 8 years ago
Can anyone recommend a good book to get started on concurrency, with discussions of models, and a few implementations such as golang and python 3.5+?<p>While I can write this kind of code, I don&#x27;t feel like I completely understand some of the concepts.
评论 #14214012 未加载
评论 #14213939 未加载
michaelmcmillanabout 8 years ago
Ouch: <a href="https:&#x2F;&#x2F;github.com&#x2F;paxos-bankchain&#x2F;pastey&#x2F;blob&#x2F;master&#x2F;app.py#L99" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;paxos-bankchain&#x2F;pastey&#x2F;blob&#x2F;master&#x2F;app.py...</a>
评论 #14214085 未加载
评论 #14214116 未加载
评论 #14214070 未加载
ciesabout 8 years ago
&gt; Write Fast Apps Using Async Python<p>When working with Python and Ruby I find 80ms responses acceptable. In very optimized situations (no framework) this can do down to 20ms.<p>Now I&#x27;ve used some Haskell, OCaml and Go and I have learned that they can typically respond in &lt;5ms. And that having a framework in place barely increases the response times.<p>In both cases this includes querying the db several times (db queries usually take less then a millisecond, Redis shall be quite similar to the extend that it does not change outcome).<p>&lt;5ms makes it possible to not worry about caching (and thus cache invalidation) for a much longer time.<p>I&#x27;ve come to the conclusion that --considering other languages-- speed is not to be found in Python and Ruby.<p>Apart from the speed story there&#x27;s also resource consumption, and in that game it is only compiled languages that truly compete.<p>Last point: give the point I make above and that nowadays &quot;the web is the UI&quot;, I believe that languages for hi-perf application development should: compile to native and compile to JS. Candidates: OCaml&#x2F;Reason (BuckleScript), Haskell (GHCJS), PureScript (ps-native), [please add if I forgot any]
评论 #14219101 未加载
jitlabout 8 years ago
&gt; Paxos.com<p>I&#x27;m confused by the relationship between Paxos, the company, and Paxos, the algorithm. Do the authors of Paxos work for Paxos?<p>Edit:<p><a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Paxos_(computer_science)" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Paxos_(computer_science)</a><p>Ah; both are named for a fictional financial systen
评论 #14215598 未加载
ipsum2about 8 years ago
The title is misleading. The blog post doesn&#x27;t cover how fast using async python is, it&#x27;s a tutorial on how to use their ORM redis library.
评论 #14213871 未加载
StreamBrightabout 8 years ago
&gt;&gt;&gt; The performance of uvloop-based asyncio is close to that of Go programs.<p>I would prefer standard benchmarks for this. I hope they submit their framework to TechEnpower benchmarks.<p><a href="https:&#x2F;&#x2F;www.techempower.com&#x2F;benchmarks&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.techempower.com&#x2F;benchmarks&#x2F;</a>
评论 #14214518 未加载
njharmanabout 8 years ago
&gt; You get the benefits of a database, with the performance of RAM!<p>One of the benefits of modern RDBMS is that they make extremely sophisticated use of RAM, and all levels of fast to slow storage below that SSD &#x2F; RAIDs &#x2F; slow single spindle.
sisciaabout 8 years ago
Quite related, but if you want to use Redis as a SQL database I wrote an extension to do just that: <a href="https:&#x2F;&#x2F;github.com&#x2F;RedBeardLab&#x2F;rediSQL" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RedBeardLab&#x2F;rediSQL</a><p>It is a relative thin layer of rust code between the Redis module interface and SQLite.<p>At the moment you can simply execute statements but any suggestion and feature request is very welcome.<p>Yes, it is possible to do join, to use the LIKE operator and pretty much everything that SQLite gives you.<p>It is a multi-thread module, which means that it does NOT block the main redis thread and perform quite well. On my machine I achieved 50.000 inserts per seconds for the in memory database.<p>If you have any question feel free to ask here or to open issues and pull request in the main repo.<p>:)
rcarmoabout 8 years ago
This is pretty neat. I&#x27;ve been using a plain Redis wrapper (aioredis) with uvloop and Sanic (<a href="https:&#x2F;&#x2F;github.com&#x2F;rcarmo&#x2F;newsfeed-corpus" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rcarmo&#x2F;newsfeed-corpus</a>), but I&#x27;m going to have a peek at subconscious.
VT_Drewabout 8 years ago
&gt;One of the common complaints people have about python and other popular interpreted languages (Ruby, JavaScript, PHP, Perl, etc) is that they’re slow.<p>Proceeds to show an animation of posting a blog post that performs no faster than if it was built using Django.
NightlyDevabout 8 years ago
&gt; 10k pageviews took ~41s<p>Might be that the server is insanely slow, but I would have no problems reaching 10k page views per second with some basic PHP and even MariaDB on a low end E3-1230 server. Pretty sure more would be quite easy to...
fritzyabout 8 years ago
It seems strange that they would claim that Python&#x27;s libuv based event loop is twice as fast as Node.js&#x27;s libuv based event loop. There&#x27;s some context missing to that statement or it&#x27;s flat out false.
评论 #14214692 未加载
hasenjabout 8 years ago
If you want performance don&#x27;t use Python.
评论 #14216734 未加载
评论 #14216102 未加载
评论 #14216582 未加载
thepropabout 8 years ago
This is to get a high performance ready app out. You could probably get an app out faster in PHP or Meteor or other prototyping framework.