简体   繁体   English

在64位操作系统上安装32位Ruby

[英]Installing 32-bit Ruby on 64-bit OS

As far as I know, when we run Ruby applications on 64-bit Ruby, it consumes more memory than 32-bit Ruby, this is due to pointer address-space. 据我所知,当我们在64位Ruby上运行Ruby应用程序时,它比32位Ruby消耗更多的内存,这是由于指针地址空间所致。

My machine has 64GB RAM, so in order to access the full 64GB of memory, I installed a 64-bit OS. 我的机器具有64GB的RAM,因此为了访问完整的64GB内存,我安装了64位OS。

  1. Is it possible to install a 32-bit Ruby on 64-bit OS? 是否可以在64位操作系统上安装32位Ruby?
  2. By installing a 32-bit Ruby on 64-bit OS, will my 32-bit Ruby be able to use 64 GB RAM? 通过在64位操作系统上安装32位Ruby,我的32位Ruby能够使用64 GB的RAM吗?
  3. What are the pros and cons of running 32-bit Ruby on a 64-bit OS? 在64位操作系统上运行32位Ruby的优缺点是什么?

I had noticed that running my Ruby on Rails application on 64-bit Ruby consumes more RAM than 32-bit Ruby. 我已经注意到,在64位Ruby上运行Ruby on Rails应用程序比32位Ruby消耗更多的RAM。 I am using Phusion Passenger so it forks or creates new Ruby processes for each request, so each individual Ruby process (user request) is limited to 2 GB in 32-bit Ruby or the overall Ruby process is limited to access only 2GB in 32-bit Ruby. 我使用的是Phusion Passenger,因此它会为每个请求派生或创建新的Ruby进程,因此在32位Ruby中每个单独的Ruby进程(用户请求)都被限制为2 GB,或者整个Ruby进程在32-露比


My Rails application codebase is large and I plan to replicate the same code as multiple Rails applications for multiple clients in a single server so every MB of RAM is important for me, so if more RAM is free I can run additional applications for additional clients. 我的Rails应用程序代码库很大,我计划在单个服务器中为多个客户端复制与多个Rails应用程序相同的代码,因此每个MB的RAM对我来说都很重要,因此,如果有更多的RAM可用,我可以为其他客户端运行其他应用程序。

For more information about the application architecture see " (Using phusion passenger + Nginx) running same rails app with multiple instance names with same port (80) ". 有关应用程序体系结构的更多信息,请参阅“ (使用phusion passenger + Nginx)使用具有相同端口(80)的多个实例名称运行相同的Rails应用程序 ”。

Is it possible to install a 32-bit Ruby on 64-bit OS? 是否可以在64位操作系统上安装32位Ruby?

  1. Yes, it is possible. 对的,这是可能的。

By installing a 32-bit Ruby on 64-bit OS, will my 32-bit Ruby be able to use 64 GB RAM? 通过在64位操作系统上安装32位Ruby,我的32位Ruby能够使用64 GB的RAM吗?

  1. No, it can't access 64 GB RAM. 不,它无法访问64 GB RAM。 32-bit processes are limited to 2 GB by default, 3 max if marked LARGE_ADDRESS_AWARE, but not more. 默认情况下,32位进程限制为2 GB,如果标记为LARGE_ADDRESS_AWARE,则最大为3 GB,但不能更多。

What are the pros and cons of running 32-bit Ruby on a 64-bit OS? 在64位操作系统上运行32位Ruby的优缺点是什么?

  1. Cons: You're limited to 2 GB of memory. 缺点:您只能使用2 GB的内存。

You're worrying about nothing, though. 不过,您无需担心。 The pointer sizes going from 32-bit (4 bytes) to 64-bits (8 bytes) only affects the pointers. 指针大小从32位(4字节)到64位(8字节)只会影响指针。 If you have 64 GB of RAM and a 64-bit processor that can use them, use the 64-bit version. 如果您有64 GB的RAM和可以使用它们的64位处理器,请使用64位版本。

...I plan to replicate the same code as multiple Rails applications for multiple clients in a single server so every MB of RAM is important for me... ...我计划在一个服务器中为多个客户端复制与多个Rails应用程序相同的代码,因此每个MB RAM对我来说都很重要...

Don't write monolithic applications, write smaller Rails apps that call central code that handles as much processing as possible for all apps calling it. 不要编写整体的应用程序,而编写较小的Rails应用程序,这些应用程序将调用中央代码,该代码可以为所有调用它的应用程序处理尽可能多的处理。 It'd be a tiny bit slower, but much more efficient memory-wise. 这会稍微慢一点,但是在内存方面要高效得多。

Look into something like RabbitMQ as the backend. 研究类似于RabbitMQ的后端。 It's amazingly efficient and great for this sort of task. 对于这样的任务,它效率极高且非常出色。 The AMQP gem is your friend. AMQP宝石是您的朋友。

Throw your data around the queues using JSON. 使用JSON将数据扔到队列中。 It makes it easy to debug. 它使调试变得容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM