Programing

Tornado 사용시기, Twisted / Cyclone / GEvent / 기타 사용시기

lottogame 2020. 5. 19. 08:02
반응형

Tornado 사용시기, Twisted / Cyclone / GEvent / 기타 사용시기


현대의 멀티 유저 웹 애플리케이션을 구축하기에 가장 적합한 프레임 워크 / 라이브러리는 무엇입니까? 비동기식 웹 서버를 사용하여 쉽게 확장 할 수 있습니다. 최고의 성능 / 확장 성 / 가장 유용한 프레임 워크 (사용하기 쉽고 개발하기 쉬운 측면)를 제공하는 솔루션은 무엇입니까 ?

좋은 기능 (웹 소켓, rpc, 스트리밍 등) 을 제공한다면 좋을 것 입니다.

각 솔루션의 장단점은 무엇입니까?


" Django 는 빠른 개발과 깨끗하고 실용적인 디자인을 장려하는 고급 Python 웹 프레임 워크입니다 . " 전자 상거래 사이트와 유사한 것을 구축하고 있다면 아마도 장고와 함께 가야 할 것입니다. 작업이 빠르게 완료됩니다. 너무 많은 기술 선택에 대해 걱정할 필요가 없습니다. 템플릿 엔진에서 ORM에 이르기까지 필요한 모든 것을 제공합니다. 앱을 구성하는 방식에 대해 약간의 의견이있을 것입니다. 또한 다른 모든 라이브러리 중에서 가장 강력한 커뮤니티를 보유하고 있으므로 쉽게 도움을받을 수 있습니다.

" Flask 는 Werkzeug, Jinja 2 및 좋은 의도에 기반한 Python의 마이크로 프레임 워크입니다 . " "마이크로 프레임 워크"는 오해의 소지가 있습니다. 이것이 Flask가 반 구운 라이브러리라는 것을 의미하지는 않습니다. 이것은 플라스크의 핵심이 매우 간단하다는 것을 의미합니다. Django와 달리 기술 결정은 없습니다. 원하는 템플릿 엔진 또는 ORM을 자유롭게 선택할 수 있습니다. 기본적으로 Jinja 템플릿 엔진과 함께 제공되지만 항상 자신의 것을 자유롭게 선택할 수 있습니다. 내가 아는 한 Flask는 API 엔드 포인트 (RESTful 서비스)를 작성하는 데 편리합니다.

" Twisted 는 파이썬으로 작성된 이벤트 중심 네트워킹 엔진입니다 . " 고성능 엔진입니다. 속도의 주된 이유는 연기 된 것입니다. 트위스트는 지연된 항목 위에 구축됩니다. 연기에 대해 모르는 사람들에게는 비동기 아키텍처를 통한 메커니즘이 달성됩니다. 트위스트는 매우 빠릅니다. 그러나 기존 웹앱을 작성하는 데는 적합하지 않습니다. 저수준 네트워킹 물건을 원한다면 친구가 뒤틀린 것입니다.

" Tornado 는 원래 FriendFeed에서 개발 된 Python 웹 프레임 워크 및 비동기 네트워킹 라이브러리입니다. 비 차단 네트워크 I / O를 사용하여 Tornado는 수만 개의 개방형 연결로 확장 할 수 있으므로 긴 폴링, WebSocket 및 기타 응용 프로그램에 이상적입니다. 각 사용자에게 오래 지속되어야합니다 " . 토네이도는 장고와 플라스크 사이에 있습니다. Django 또는 Flask로 무언가를 쓰고 싶지만 더 나은 성능이 필요하면 Tornado를 선택할 수 있습니다. 제대로 설계되면 C10k 문제를 매우 잘 처리 할 수 ​​있습니다.

" Cyclone 은 Tornado API를 Twisted 프로토콜로 구현하는 Python 용 웹 서버 프레임 워크입니다 . " 트위스트만큼이나 성능이 뛰어나고 기존의 웹앱을 작성하기 쉬운 것을 원한다면 어떻게해야할까요? 사이클론에게 인사하십시오. 나는 토네이도보다 사이클론을 선호합니다. 토네이도와 매우 유사한 API가 있습니다. 사실, 이것은 토네이도의 포크입니다. 그러나 문제는 그것이 상대적으로 작은 공동체라는 것입니다. 알렉산드르 피오리 (Alexandre Fiori)는 레포에 대한 유일한 주요 커미터입니다.

" Pyramid 는 일반적인 오픈 소스 Python 웹 응용 프로그램 개발 프레임 워크입니다. 주요 목표는 Python 개발자가 웹 응용 프로그램을보다 쉽게 ​​만들 수 있도록하는 것입니다." 나는 실제로 피라미드를 사용하지는 않았지만 문서를 살펴 보았습니다. 내가 이해에서 피라미드와 매우 유사하다 플라스크 나는 어디든지 당신이 피라미드를 사용할 수 있다고 생각 플라스크가 적절한 것 같다 그 반대의 경우도 마찬가지입니다.

편집 : 다른 프레임 워크 검토 요청을 환영합니다!

출처 : http://dhilipsiva.com/2013/05/19/python-libraries-django-twisted-tornado-flask-cyclone-and-pyramid.html


이것은 분명히 다소 편향된 답변이지만 잘못된 답변 과는 다릅니다 . 항상 Twisted를 사용해야합니다. 전에 비슷한 질문 에 답변 했지만 귀하의 질문이 완전히 다르기 때문에 다음과 같은 이유가 있습니다.

"최고의 성능"

Twisted는 speed.twistedmatrix.com 웹 사이트 에서 지속적으로 성능을 모니터링합니다 . 또한 PyPy의 유사한 사이트 에서 모니터링 하는 첫 번째 프로젝트 중 하나이므로 Python의 고성능 응용 프로그램과 관련된 런타임에서 Twisted의 우수한 성능을 보장합니다.

"확장 성"

내가 알기로는 나열된 프레임 워크 중 어느 것도 자동 스케일링을 기본적으로 지원하지 않습니다. 그것들은 모두 통신 프레임 워크이므로 스케일링 노드 사이에서 통신하려면 작업을 수행해야합니다. 그러나 Twisted는 로컬 다중 처리를 기본적으로 지원 한다는 이점이 있습니다. 공정 하게도 Tornado 용 타사 애드온 이있어 동일한 작업을 수행 할 수 있습니다. 최근 릴리스에서 Twisted는 코어간에 작업을 공유 할 수있는 방법의 수를 늘리는 기능추가 했으며 해당 영역에서 작업이 진행 중입니다. 트위스트는 몇 가지가 잘 통합 , "네이티브" 당신이 추구 원하는 스케일링 관용구를위한 건설 키트를 제공하는 RPC 프로토콜을.

"가장 유용한"

많은 사람들 이 Twisted가 매우 유용하다고 생각합니다 . 너무 많은 사람들이 그것을 확장하고 확장 기능을 사용할 수 있도록했습니다.

"기능"

Twisted는 기본적으로 다음을 포함합니다.

이 마지막 부서에서 최소한 Twisted는 기본 제공 기능의 확실한 승자로 보입니다. 그리고이 모든 것이 2MB 이상의 패키지로 제공됩니다!


@Glyph 응답이 마음에 듭니다. Twisted는 매우 포괄적이고 풍부한 파이썬 프레임 워크입니다. 트위스트와 토네이도는 매우 비슷한 디자인입니다. 그리고 나는이 디자인을 매우 좋아합니다.

  • 빠르다
  • 이해하기 쉬운
  • 확장하기 쉬운
  • C 확장이 필요하지 않습니다
  • PyPy에서 작동합니다.

그러나 나는 토네이도 를 강조하고 싶습니다 . Twisted와 마찬가지로 Tornado는 콜백 스타일 프로그래밍을 사용하지만 tornado.gen.engine( twisted.internet.inlineCallbacksTwisted에서)를 사용하여 인라인 할 수 있습니다 .

코드베이스

가장 좋은 의견은 http://cyclone.io 사이트입니다. cyclone은 다음 과 같은 이유로 Twisted와 Tornado를 혼합하려고 시도합니다.

Twisted is one of the most mature libraries for non-blocking I/O available to the public. Tornado is the open source version of FriendFeed’s web server, one of the most popular and fast web servers for Python, with a very decent API for building web applications.

The idea is to bridge Tornado's elegant and straightforward API to Twisted's Event-Loop, enabling a vast number of supported protocols.

But in 2011 tornado.platform.twisted was out which brings similar functionality.

Performance

Tornado has much better performance. It also works seamlessly with PyPy, and get huge gain.

Scalability

The same like Twisted. Tornado has tornado.process and a lot of rpc services implemented on top of it.

Functionality

There are 71 Tornado based package, compared to 148 Twisted's and 48 Gevent's. But if you look carefully and compute median of packages upload time, you will see that Twisted ones are the oldest, then Gevent and Tornado the freshest. Furthermore there is tornado.platform.twisted module which allows you to run code written for Twisted on Tornado.

Summary

With Tornado you can use a code from Twisted. There is no need to use cyclone which only twists your code (your code becomes more messy).

As for 2014, Tornado is considered as widely accepted and default async framework which works both on python2 and python3. Also the latest version 4.x brings a lot of functionality from https://docs.python.org/dev/library/asyncio.html.

I wrote an article, explaining why I consider that Tornado - the best Python web framework where I wrote much more about Tornado functionality.


(UPDATE: I'm sadly surprised about how few answers here recommend or even mention Gevent—I don't think it's in proportion to the popularity, performance and ease of use of this excellent library!)

Gevent and Twisted are not mutually exclusive, even though the contrary might seem obvious at first. There is a project called geventreactor which allows one to relatively smoothly leverage the best of both worlds, namely:

  • The efficient and cheap (cooperative green) thread model of Gevent, which is much easier to program in when it comes to concurrency—frankly, Twisted's inlineCallbacks is simply not up to the job in terms of performance when it comes to many coroutines, and neither in terms of ease/transparency of use: yield and Deferreds everywhere; often hard to build some abstractions; horrifyingly useless stack traces with both bare Deferreds as well as, and even more so with @inlineCallbacks.
  • All the built-in functionality of Twisted you can ever dream of, including but not limited to IReactorProcess.spawnProcess.

I'm personally currently using Gevent 1.0rc2 with Twisted 12.3 bridged by geventreactor. I have implemented my own as-of-yet unpublished additions and enhancements to geventreactor which I will publish soon, hopefully as part of geventreactor's original GitHub repository: https://github.com/jyio/geventreactor.

My current layout allows me to program in the nice programming model of Gevent, and leverage things such as a non-blocking socket, urllib2 and other modules. I can use regular Python code for doing regular things, as opposed to the learning curve and inconvenience of doing even simple, basic things the Twisted way. I can also easily use most 3rd party libraries that are normally either out of question with Twisted, or require the use of threads.

I can also completely avoid the awkward and often overly complex callback based programming by using greenlets (instead of Deferreds and callbacks, and/or @inlineCallbacks).

(This answer was written based on my personal experiences having used both Twisted and Gevent in real life projects, with significantly more experience using Twisted (but I don't claim to be a Twisted expert). The software I've had to write hasn't had to use too many of Twisted's features, so depending on the set of features you require of Twisted, the (relatively painless) extra complexity of mixing Gevent and Twisted might not be worth the trouble.)

참고URL : https://stackoverflow.com/questions/13941903/when-to-use-tornado-when-to-use-twisted-cyclone-gevent-other

반응형