高性能 REST API - 哪种语言/堆栈? [英] High-performance REST API - Which language/stack?

查看:39
本文介绍了高性能 REST API - 哪种语言/堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Ruby on Rails 开发一个站点.我想单独开发 REST API (JSON) 以最大限度地提高性能,Rails 堆栈占用的太多了.

I am developing a site using Ruby on Rails. I would like to develop the REST API (JSON) separately to maximize performance, the Rails stack just takes away too much.

是否有任何性能基准?你认为什么会产生最好的表现?我目前正在考虑以下问题,因为这是我的经验.还有什么我应该考虑的吗?它应该是轻量级的.

Are there any performance benchmarks out there? What do you think would yield the best performance? I am currently thinking about the following, because that's what I have experience with. Is there anything else I should consider? It should be lightweight.

  • node.js
  • Scala 喷雾 (http://spray.io/)
  • Ruby Sinatra

谢谢!

推荐答案

总结:最大限度地提高您作为开发人员的表现.使用您最了解的堆栈.首先让它发挥作用,然后让它快速起来.

Summary: Maximize your performance as a developer. Use stack you know best. First make it work, then make it fast.

是否有任何性能基准?

有各种各样的基准测试.假设,node.js 可以处理 100k HPS(每秒 helloworlds)而 Sinatra 只能处理 80k.它告诉你什么?没什么.

There are all kinds of benchmarks out there. Let's say, node.js can handle 100k HPS (helloworlds per second) and Sinatra can only do 80k. What does it tell you? Nothing.

此外,有时更高的性能需要付出巨大的代价.以 ruby​​ C 扩展为例.当然,C 的运行速度比 Ruby 快,但它会阻止其他线程在其他内核上运行(因为 GIL).

Also, sometimes higher performance comes at a great cost. Take ruby C extensions, for example. Sure, C runs faster than Ruby, but it prevents other threads from running on other cores (because of GIL).

因此,不要仅根据互联网上的基准数据来选择技术.除了原始 HPS 数字外,还有很多因素需要考虑.

So, don't choose tech only by benchmark figures from the internet. There are so many factors to consider besides raw HPS number.

LINK:如果你觉得 Rails 太重了,你应该试试 rails-api.它基本上是 Rails 的精简版(您不需要 api 服务器中的 cookie 身份验证或 MSIE 渲染助手之类的东西).

LINK: If you think Rails is too heavy, you should try rails-api. It's basically a stripped down version of Rails (you don't need things like cookie authentication or MSIE rendering helpers in an api server).

我运行一个 API 服务器来处理一些负载.第一个版本是用 Rails 编写的.然后我想嘿,Rails 臃肿 (c),让我们用 Sinatra 重写所有内容".然后我一波又一波的沮丧袭来.事实证明,Rails 做了很多我不喜欢的小而有用的事情.我放弃了,再次用 Rails 重写它(应用吸取的教训),从此过上了幸福的生活.

I run an API server that handles some load. First version was written with Rails. Then I thought "Hey, Rails Is Bloated (c), let's rewrite everything with Sinatra". And then I had waves of frustration coming one after another. It turned out that Rails does a lot of small but helpful things which I didn't appreciate. I gave up, rewrote it with Rails again (applying lessons learned) and lived happily ever since.

这篇关于高性能 REST API - 哪种语言/堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆