Reading recent papers is a good way to come up with ideas for things to work on. For example, the last section of a paper often lists open problems and possible topics for future research, and they may also be scattered throughout the paper. Of course the author or other readers may be working on them, but that difficulty is unavoidable for any problem that isn't communicated privately to you. Some of the advantages of this approach are:
You have some evidence that the answer isn't already known. Of course maybe the author just didn't know it, but at least you are getting an expert opinion (which is particularly helpful if you aren't an expert yourself).
Your work may be of interest to other readers of this paper. This avoids the difficulty of making up a topic and then discovering that you are unable to interest anyone in it.
The published papers on the topic let you calibrate your level of knowledge. If you can read them, then you probably know enough to work on extensions. If you can't, then you need to learn more.
There's some reason to think progress may be possible.
By contrast, I would absolutely avoid working on famous problems. They satisfy 1 to 3 nicely, but the "famous" requirement specifically filters out any reasonable likelihood of a full solution, and progress towards a solution may be very difficult. Unless you are extraordinarily talented or lucky, choosing problems because of their fame is a big step in the direction of becoming a failure as a researcher or even a crackpot. Even if you are extraordinarily talented, there's no harm in starting with a warm-up goal, and this avoids the difficulty that many people have trouble estimating their own abilities.
As for how long it will take to solve a research problem, this is unanswerable. If you are really lucky, you might make important progress within a few weeks. If you get stuck in a rut or are missing some background, you might work fruitlessly for years on a problem that's not actually all that difficult. And of course problems vary enormously in their difficulty. With enough experience, you might be able to estimate how difficult or time-consuming certain problems might be, so you could guess what might make an appropriate Ph.D. thesis problem, for example. However, even experts are sometimes wrong, and developing this sort of feeling takes substantial research experience. When you are starting out, I don't think there's any reliable way to guess these sorts of things. This is one reason why Ph.D. advisors are important: they can offer feedback and advice based on intuitions the student is still developing.
If you are working on research without experience or expert guidance, you could use the following guidelines. Don't give up too quickly: anything worth publishing is worth spending weeks beating your head against with no apparent progress. (Of course I don't mean staring at a blank piece of paper, but trying ideas and discovering they don't work, looking at special cases and examples, studying background that may be relevant, etc.) Once you have a solid background in the relevant mathematics, which could take a long time depending on the field, you should probably be getting somewhere over a period of months. By "somewhere", I don't necessarily mean clear progress towards a solution, but you should be able to articulate an understanding of the problem you didn't have when you started, you should be coming up with tangential or spin-off ideas that may not solve the problem but could be interesting in their own right, etc. The ultimate test of successful research isn't whether you accomplish your original goals, but rather whether you find something interesting along the way. On the other hand, if months go by and you don't seem to be coming up with any interesting ideas or understanding, then this is probably not a fruitful research topic with your current level of background and experience.
Of course you shouldn't take any advice like the last paragraph too seriously. Research is a highly personal topic, and many people have different research styles. However, it may give you an idea of one reasonable approach.