This phase I/Ib trial studies the side effects and best dose of ibrutinib when given together with pembrolizumab and to see how well they work in treating patients with non-Hodgkin lymphoma that has come back or does not respond to treatment. Monoclonal antibodies, such as pembrolizumab, may interfere with the ability of cancer cells to grow and spread. Ibrutinib may stop the growth of cancer cells by blocking some of the enzymes needed for cell growth. Given pembrolizumab and ibrutinib may work better in treating patients with non-Hodgkin lymphoma.