Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

With 35 connections, my bitcoind consumes 581Mb of memory which is over half of my total memory in VPS (1024 total) and I need memory also for other services such as apache2 and mysql on my server. Can I take any steps to limit the resources used by bitcoind to about a nice round number 256Mb without severely limiting the bitcoind's ability to function properly? I suppose I can limit the number of max inbound/outbound connections in bitcoin.conf, but then what would be a good limit?

share|improve this question

migrated from serverfault.com Aug 14 '11 at 13:19

This question came from our site for system and network administrators.

    
That's an inappropriate tone of reply, and he's talking about a daemon process. I consider limiting the memory of daemon processes very relevant. One doesn't usually explore this with desktop apps. It should be migrated back to serverfault... –  Jeff Ferland Aug 14 '11 at 13:20
1  
Agree, should go back to serverfault. Anyway - how are you measuring consumed/used memory? Can you tell us more about the OS and other config. –  EightBitTony Aug 14 '11 at 13:24
    
OS is Ubuntu server 11.04 (not the best choice I know). I used openvz (shared kernel 2.6.18) control panel provided by the hosting company to see that too much memory is being used. Then I used "top" to first identify the process consuming most resources. Then I used "pmap -x" with bitcoind pid to see how much it uses exactly. Basically I used all the commands every computer owner should know, probably thats why it was moved from serverfault to superuser. –  jaz Aug 14 '11 at 14:17
    
@jaz I know it's been a few years, but just for reference: Your comment above provides no useful information. Which field in top? What did you see in pmap -x? Physical memory or virtual memory? –  David Schwartz Jul 15 at 23:08

3 Answers 3

up vote 0 down vote accepted

Take a look at http://stackoverflow.com/questions/4983120/limit-memory-usage-for-a-single-linux-process

I think softlimit as a wrapper program is what you need to use. I don't know without testing whether that will force swapping or just kill it.

share|improve this answer
    
killing the process is bad, if the software running it, is stable. Looks like OpenVZ VPS doesn't provide any swap space either (used command "free") so it looks like I'm pretty much out of luck here. –  jaz Aug 14 '11 at 14:55
    
I took a closer look the flags -- I think you can separate real memory limits from total memory limits, so it should swap. –  Jeff Ferland Aug 14 '11 at 17:40
    
Thanks Jeff, for the lack of a better answer I have accepted yours –  jaz Aug 16 '11 at 9:18

bitcoind uses a ton of memory while it's downloading the blockchain. Check out these steps on how to set up your swap space correctly on Ubuntu:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

Additionally, you can check out the torrent download of the blockchain. As long as you trust the file, this can help speed up the time to download the blockchain.

http://sourceforge.net/projects/bitcoin/files/Bitcoin/blockchain/bootstrap.dat.torrent/download

share|improve this answer

You can tweak mysql and apache to use work with much less ram than their defaults, this is a different subject though and obviously it may not be an option (based) on the volume of your traffic etc...

...bitcoind

Its interesting that its connected to so many nodes, on default it only does about 8 connections last time I looked

I'd suggest adding this to your ~/.bitcoin/bitcoin.conf to at least limit the sessions for now:

maxconnections=8

(use more if you want to sync the entire blockchain (from scratch) faster, then reduce it afterwards although I'm uncertain how/if this will effect its footprint.)

I've got version 80600 running at the moment, 8 connections and its running (RSS) around 320M

I think bitcoind will always need a big chunk amount or ram though... (https://github.com/bitcoin/bitcoin/issues/2485)...

I'd be interested to see what can be learned about reducing its memory footprint. I will start research this myself. ( I'm running well over 10 coins on a server I host and just had to bump its ram to 4g as it was swapping all over the place, so it would be good to know )

For the moment I suggest a few tweaks to mysqld and apache. There is a vast array of options.. For mysqld checkout mysqltuner.pl and start bumping numbers (plenty of tutorials out there for this but I suggest small changes at a time)

..this is from a reasonably small mysqld I run on one of my VMs (debian 6), its around 128Mb in footprint right now (but could potentially go up to 164Mb)..

example:

[mysqld]
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
query_cache_limit   = 1M
query_cache_size        = 16M

[mysql]
[isamchk]
key_buffer      = 8M
sort_buffer_size = 8M

^^ (If mysqld can run on a raspberry pi this can be even reduced much further)

...if you're having stability issues I'd suggest at least creating a swapfile and activate it.

Swapfiles may not be option depending on the virtualization used but its better than things crashing I assume.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.