# HttpClient & 네트워킹 (.NET) > HttpClient, HttpClientFactory, request/response, 오류 처리, retry policies, async 패턴 - 20 면접 질문 - Mid-Level - [면접 질문: .NET](https://sharpskill.dev/ko/technologies/dotnet/interview-questions.md) ## 1. HttpClient를 직접 인스턴스화하는 대신 IHttpClientFactory를 사용하는 이유는 무엇입니까? **답변** IHttpClientFactory는 HttpClient 인스턴스의 수명 주기를 자동으로 관리하고 socket exhaustion을 방지합니다. using 문에서 HttpClient를 직접 인스턴스화하면 disposal 후에도 열려 있는 TIME_WAIT 상태의 연결 문제가 발생할 수 있습니다. IHttpClientFactory를 사용하면 Polly로 복원력 정책을 구성하고 연결 풀링을 효율적으로 관리할 수도 있습니다. ## 2. Named Client와 Typed Client의 주요 차이점은 무엇입니까? **답변** Typed Client는 HTTP 호출 로직을 의존성 주입과 함께 전용 클래스에 캡슐화하는 반면, Named Client는 IHttpClientFactory.CreateClient(name)을 통해 가져옵니다. Typed Client는 관심사 분리가 더 우수하며 설정과 비즈니스 로직을 캡슐화하여 단위 테스트를 용이하게 합니다. Named Client는 복잡한 비즈니스 로직 없이 여러 다른 설정이 필요한 간단한 경우에 유용합니다. ## 3. 애플리케이션의 모든 HttpClient 인스턴스에 전역 타임아웃을 구성하려면 어떻게 합니까? **답변** ConfigurePrimaryHttpMessageHandler를 통해 타임아웃을 구성하면 factory가 생성하는 모든 클라이언트에 적용되는 handler 수준의 타임아웃을 정의할 수 있습니다. 이 접근 방식은 설정을 중앙 집중화하고 코드 중복을 방지합니다. 각 HttpClient에 개별적으로 타임아웃을 구성할 수도 있지만, 여러 클라이언트가 구성된 대규모 애플리케이션에서는 유지 관리가 어려워집니다. ## 17개 추가 질문 이용 가능 - HTTP 응답의 본문을 문자열로 읽을 수 있는 메서드는 무엇입니까? - HttpClient 파이프라인에서 DelegatingHandler의 역할은 무엇입니까? 무료로 가입하기: https://sharpskill.dev/ko/login ## 기타 .NET 면접 주제 - [C# 기초](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/csharp-basics.md): 25개 질문, Junior - [LINQ & Delegates](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/csharp-linq-delegates.md): 20개 질문, Junior - [C# 언어 핵심 요소](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/csharp-language-essentials.md): 15개 질문, Junior - [ASP.NET Core 기초](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/aspnet-core-fundamentals.md): 18개 질문, Junior - [ASP.NET Core 요청 수명 주기](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/aspnet-core-request-lifecycle.md): 20개 질문, Junior - [Configuration & Settings](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/configuration-settings.md): 20개 질문, Junior - [애플리케이션 라이프사이클](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/application-lifecycle.md): 20개 질문, Junior - [Dependency Injection](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/dependency-injection.md): 24개 질문, Mid-Level - [Entity Framework Core](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/entity-framework-core.md): 25개 질문, Mid-Level - [Minimal APIs](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/minimal-apis.md): 18개 질문, Mid-Level - [Web API 개발](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/web-api-development.md): 22개 질문, Mid-Level - [ASP.NET Core의 Async](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/async-aspnet-core.md): 20개 질문, Mid-Level - [Authentication & Authorization](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/authentication-authorization.md): 18개 질문, Mid-Level - [JSON 직렬화](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/json-serialization.md): 20개 질문, Mid-Level - [Entity Framework Core 고급](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/ef-core-advanced.md): 25개 질문, Mid-Level - [C# 고급 기능](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/csharp-advanced-features.md): 20개 질문, Mid-Level - [Clean Architecture](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/clean-architecture.md): 20개 질문, Mid-Level - [Logging, Monitoring & Observability](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/logging-monitoring.md): 22개 질문, Mid-Level - [단위 테스트와 xUnit](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/unit-testing-xunit.md): 20개 질문, Mid-Level - [통합 테스트](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/integration-testing.md): 18개 질문, Mid-Level - [Docker & Containerization](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/docker-containerization.md): 16개 질문, Mid-Level - [NuGet 패키지 관리](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/nuget-package-management.md): 16개 질문, Mid-Level - [Memory Management & GC](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/memory-management-gc.md): 22개 질문, Senior - [리액티브 프로그래밍](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/reactive-programming.md): 24개 질문, Senior - [Async/await 및 패턴](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/async-await-patterns.md): 26개 질문, Senior - [.NET 디자인 패턴](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/dotnet-design-patterns.md): 24개 질문, Senior - [성능 최적화](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/performance-optimization.md): 22개 질문, Senior - [보안 및 모범 사례](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/security-best-practices.md): 24개 질문, Senior - [SignalR 및 실시간](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/signalr-realtime.md): 22개 질문, Senior - [마이크로서비스 아키텍처](https://sharpskill.dev/ko/technologies/dotnet/interview-questions/microservices-architecture.md): 25개 질문, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ko/technologies/dotnet/interview-questions/httpclient-networking