If someone casts Prosperity with X being 100 and one player has 50 cards and the other has 60, does the one with 50 cards lose first since he runs out first or do you wait until the spell resolves and it ends up to be a tie?
It will be a draw, both players lose at the same time.
MtG uses a system of state-based actions This is a sort of clean-up system that checks the game state almost continuously.
- State-Based Actions
704.1. State-based actions are game actions that happen automatically whenever certain conditions (listed below) are met. State-based actions don’t use the stack.
704.3. Whenever a player would get priority (see rule 116, “Timing and Priority”), the game checks for any of the listed conditions for state-based actions, then performs all applicable state-based actions simultaneously as a single event.
Priority is the game's term for who has the right to take actions. Generally, whenever something happens such as a spell is cast or resolves, or steps/phases change, the active player (the player whose turn it is) gets priority. Only the player with priority may cast spells, activate abilities, etc. The player with priority may also pass priority, giving it to the next player in turn order. This continues until all players have passed priority in succession and the stack is empty, then the current step or phase ends. This is how the game progresses.
Before a player gets priority, however, state-based actions are checked.
116.3b The active player receives priority after a spell or ability (other than a mana ability) resolves.
State-based actions are not checked while a spell resolves, only immediately after it has resolved:
704.4. Unlike triggered abilities, state-based actions pay no attention to what happens during the resolution of a spell or ability.
Therefore in your case it is not important which player had more cards in his library. Both players lose at the same time because they attempted to draw a card from an empty library:
704.5. The state-based actions are as follows:
704.5b If a player attempted to draw a card from a library with no cards in it since the last time state-based actions were checked, he or she loses the game.