There is little information regarding the dynamics of fermentation products and the bacterial community in silage prepared with alfalfa (MS), perennial ryegrass (LP), and their mixture in the karst region. In this study, we explored the effects of combining MS with LP in different ratios (100% MS, 70% MS + 30% LP, 50% MS + 50% LP, 30% MS + 70% LP and 100% LP; fresh matter basis) on silage chemical composition, fermentation quality, bacterial communities and predicted functions during the ensiling process. Each treatment was prepared in triplicate and stored at room temperature (22–25°C) for 7, 15, and 45 days. The dry matter (DM) and water-soluble carbohydrate content of the silages increased as the LP proportion in the mixed silage increased; at 45 days, the 70% MS + 30% LP, 50% MS + 50% LP and 30% MS + 70% LP silages contained higher (p < 0.05) CP content than the 100% MS and 100% LP silages. The 30% MS + 70% LP and 100% LP silages exhibited lower (p < 0.05) pH and higher (p < 0.05) LA content than the other silages; at 45 days, none of the silages contained PA or BA. As fermentation proceeded, the abundance of harmful (Enterobacteriaceae and Sphingomonas) and beneficial (Lentilactobacillus, Lactiplantibacillus, Secundilactobacillus, and Levilactobacillus) microorganisms decreased and increased, respectively, as the LP proportion in the mixed silage increased. The predicted functional distribution of microbial communities and metabolic pathways revealed that the 30% MS + 70% LP and 100% LP silages had a stronger capacity for fermentation and a weaker capacity for nitrate reduction than the other silages. Moreover, as the fermentation proceeded, the 30% MS + 70% LP and 100% LP treatments enhanced the functions of “Metabolism,” “Genetic information processing” and “Organismal systems” at level 1, the functions of “Amino acid metabolism” and “Nucleotide metabolism” at level 2, and the functions of “Metabolic pathways,” “Biosynthesis of secondary metabolites,” “Biosynthesis of antibiotics” and “Purine metabolism” at level 3. Thus, adding LP could improve the fermentation quality of MS silage by changing the composition and metabolic function of microbes; furthermore, ensiling 30% alfalfa with 70% ryegrass can produce high-quality silage in the karst region.