I get pain and swelling of the knees on most rides. Having a good bike fit is key, I really hated riding before I got my bike re-fit. Still I do have problems with the knees but not as severe. Mine stems from prior injury from bowling competitively and running.

For the swelling I take 4 ibuprofen, this dosage was recommended by my doctor. I would definitely consult yours before popping that much ibuprofen! Otherwise scooting back on the saddle does provide minor relief, sometimes I just get too far up on mine and that is not how my bike was fitted for me.