Will my python virtual environment wear down my SSD?
So I read that virtual machines tend to degrade SSDs, despite them being faster than HDDs. I'm completely new to python and I want to use Conda to create virtual environments so I don't have to keep track of a million packages. In the context of programming, is the term virtual environment different from virtual machines? I don't wanna wear down my SSD.
- oyubirLv 67 months agoFavorite Answer
Virtual environment is not a virtual machine.
SSD do not like to be rewriten often. Well, no disk like that. But SSD even less. When you use a SSD it is quite important to try to use them uniformly and, even better, to avoid writes. That is why it is often advised to use ramdisk as tmp file for system with no hard disk, or do avoid using swap, or to use a fusionfs to have a read-onjy system partition, with non persistent write capacity, etc, etc.
Read any documentation on installing an OS on a raspberry pi (which, usually, use a low quality SSD : SD cards are low quality SSD)
Virtual machine use a file as an image of an hard disk. Each modification, and even each read of the virtual hard disk (including modifications swapfile in the virtual machine) will lead to a write of the image file on the host. If the host use a SSD, then that SSD will be heavily written.
But python virtual env has nothing to do with that. It is just a local storage of python packages. It allows to have, on the same machine, different configurations of python installations (in this virtual env, version 2.3 of package foo is installed, in that other env, version 2.2 is used, ...)
Once the virtual env is set up, using it does not generate any writing. Not more than any regular programs (it depends on the program ; obviously, if the program writes a lot, virtual env or not, the disk will be written a lot)
So short answer is "no"
Plus, indeed, you can choose and configure your SSD so that it is less sensible to that.
- ChrisLv 77 months ago
A virtual machine and a virtual environment are not the same thing, no.
A virtual machine means you can run a different OS on a virtual computer, a program that emulates hardware. Since a computer usually needs a hard drive, the virtual machine uses a big file for that. This is what wears down SSDs. None of that has any connection to using a virtual environment with Python.
- PyrusLv 67 months ago
That will depend on the SSD then. You can't just go and buy any cheap SSD for less than a 100$ a TB. You have to check numerous upon numerous margins with which you want to work. First thing's first:
What is the architecture? Is it TLC, MLC, or SLC? SLC is best for longevity, which is why they are also very expensive. MLC is the middle line for something that lasts quite long, but not even close to SLC. TLC is for very light users who just want performance and don't really have much read/write to do, meaning the bit cells won't be used as much.
Does it support 3D NAND? This is more on the technical level, as you would be worried about the lithography that the SSD is based on. So, instead of relying on shrinking technology, you are stacking the cells vertically. I would prefer this option, as it leaves less of an error margin during manufacturing, because the smaller the lithography, the greater you'll need to pay attention to detail during the manufacture.
What is its TBW (TerraBytes Written): You might see on cheap SSDs that they say that it would take a mean time of about 1000000 hours before errors start occurring. But of course, even if this way 100% accurate, there are a lot of factors that can easily shorten the lifetime of your SSD. In this case, it's TBW, as it states how many TerraBytes you can write/rewrite on an SSD before it wears out. In other words, it's the SSD's endurance. Another term for it is DWPD, meaning Drive Writes Per Day. Basically, it tells you how many TBs you can write on a daily basis for a certain number of years before the SSD finally dies (or at least start causing you trouble).
What controller does it use? I cannot stress this enough. Most often, the cause of failure of an SSD is due to bad controllers. Usually they use SM2256 Silicon Chip controllers, but yea, I won't delve into this too much. Suffice to say that if your SSD dies due to a bad controller, you'd better hope that you have a dedicated hardware and software that is capable of reading NAND flash perfectly to be able to make recoveries, otherwise your SSD is as good as dead. It's virtually impossible to recover any data at this stage. It's actually even harder than failing HDDs (usually the spinning plates would be completely fine, so there is a greater likelihood to recover data from a "dead" HDD than a dead SSD).
Does it have DRAM or maybe an SLC cache? This is likewise a crucial question, because the DRAM is used to store the location of data in an SSD, as the data you put on an SSD is not static and is ever changing. As DRAM is faster than the flash on an SSD, locating the data is faster and since you are not using the storage flash, it has less wear than what would happen in a DRAM-less setup.
So, if you have to choose, I'd go with something like a Kingston SSD with 1 TB storage, MLC architecture that supports SLC caching and 3D NAND, and that has a rather large TBW. Price should be something around 210$ for something good.