2010년 6월 18일 금요일
asp.net 성능 튜닝 (processModel)
2010년 3월 15일 월요일
2010년 3월 14일 일요일
2010년 2월 20일 토요일
2010년 2월 15일 월요일
enum의 Flag 연산
다음의 코드는 열거형의 Flag연산을 쉽게 정리해 놓은 것입니다.
[Flags]
public enum Column
{
None = 0,
Priority = 1 << 0,
Customer = 1 << 1,
Contract = 1 << 2,
Description = 1 << 3,
Tech = 1 << 4,
Created = 1 << 5,
Scheduled = 1 << 6,
DueDate = 1 << 7,
All = int.MaxValue
};
[Flags] 속성을 사용하면 아래와 같은 코드가 가능합니다.(두 속성을 하나의 변수에 담는 것):
값이 존재하는지 확인:
특정 값을 추가:
특정 값을 제거:
특정 값을 반전(1은 0으로, 0은 1로):
모든 값 삭제:
모든 값 설정:
특정 값을 제외하고 모두 설정:
2010년 2월 1일 월요일
WCF 성능 향상 팁
WCF Performance Optimization Tips
.NET Framework 3.0 부터는 Enterprise Services 를 잘 구현할 수 있는 WCF(Windows Communication Foundation) 라이브러리를 제공합니다. 특히 최근 .NET Framework 3.5 SP1 에서는 서비스의 통합 뿐만 아니라 Enterprise Services Bus 를 구현하여 최상의 SOA(Services Oriented Architecture) 를 구현할 수 있는 프레임워크입니다.
그렇기 때문에 기존에 .NET 이 제공하던 XML Web Services 와 WCF 를 동일 선상에서 비교하거나 생각하는 것은 굉장히 위험할 수 있습니다. 가끔 BasicHttpBinding 이나 WSHttpBinding 등을 사용하여 IIS 에 호스팅 할 경우 성능에 대해 고민을 해 보신 분들도 계실 겁니다. 예전에 XML Web Service 로 잘 수행했던 프로젝트를 WCF 를 사용하여 만들었을 경우 서버가 자주 뻗는 경우도 있었을 것입니다.
Web Based Performance Optimization Tips
즉, 일반적으로 IIS 에 호스팅되는 Web Application 이나 XML Web Service 의 성능을 향상시키기 위해서는 Thread 나 Connection 을 늘려주는 방법으로 성능 튜닝을 할 수 있었습니다. ( default 는 .NET Framework 1.1 기준 )
- Max Connection - default 2
- Max IO Threads - default 20
- Max Worker Threads - default 20
- Min Free Threads - default 8
- Min Local Request Free Threads - default 4
잘 모르시겠다구요~? MSDN 에 보시면 나옵니다. 각각 항목은 단지 권장 값이고 튜닝을 하기 위해서는 "추천 수치 * CPU 개수" 가 바로 최상의 성능을 낼 수 있는 Threads 나 Connection 이 됩니다. 사실 기본 값으로 서버 성능을 최상으로 발휘하기에는 무리가 있습니다.
WCF Based Performance Optimization Tips
하지만 WCF 에서는 이러한 성능 튜닝 방법은 전혀 다른 차원의 이야기 입니다. 왜냐하면 Web Application 이나 XML Web Service 와 달리 WCF 는 ASP.NET Pipeline(파이프라인) 을 거치지 않기 때문입니다.
Microsoft 의 WCF 개발 팀은 이런 부분에서 참 아이러니한 이야기를 합니다.
"DDos 공격을 방지하기 위함이다!" 라고...
틀린 이야기는 아니죠. ASP.NET HttpRuntime 환경을 그대로 WCF 환경으로 적용하기에는 WCF 프레임워크의 아키텍처와는 너무나 비호환적이기 때문인 것 같습니다. 다시 바꾸어 말하면, WCF 는 내부적인 ASP.NET 파이프라인을 타지 않습니다. 그렇기 때문에 기본 옵션의 Session 이나 Call 옵션으로 Service Host 가 락(Lock) 에 걸리는 상황이 옵니다.
MaxConcurrentSessions 는 Default 가 10 이므로, Closing 되지 않은 클라이언트의 세션이 이를 초과하게 되면 Lock 이 걸리게 됩니다. 아래는 간단한 예제이지만, Closing 을 잘해주더라도 Multi Thread 로 테스트를 해 보시면 금방 Lock 이 걸리게 할 수 도 있답니다.
namespace WcfService1Console { class Program { static void Main(string[] args) { for (int i = 0; i < 20; i++) { ServiceReference1.Service1Client client = new WcfService1Console.ServiceReference1.Service1Client(); Console.WriteLine(i + " " + client.GetData(3)); } } } } |
WCF 서비스는 기본값이 Max Session 이 10개에 도달하면 클라이언트의 연결을 거부합니다. Session Lock 이 걸리고 이전의 세션이 끝나야 다른 Session 의 연결을 수락하게 됩니다. WCF Session 은 HTTP Session 과 다르며, 클라이언트와 서버의 인스턴트를 연결하는 인증 매커니즘과 비슷합니다. WCF 의 SessionMode 를 NotAllowed 로 동작하도록 세션 사용을 하지 않도록 설정해도 되지만, 이러한 방법으로는 클라이언트와 서버간의 연결을 보장하지 않을 뿐이지, 실제로 세션이 연결이 되지 않는 것은 아니기 때문에, 퍼포먼스 향상을 위한 좋은 방법이라고 볼 수는 없습니다.
그리하여 WCF 의 퍼포먼스를 향상시키기 위해서는 ASP.NET 과는 별도의 Throttling 환경의 조정이 필요합니다.
<behaviors> <serviceBehaviors> <behavior name="WcfWsHttpSvc.Service1Behavior"> <!-- 메타데이터 정보를 공개하지 않으려면 배포하기 전에 아래의 값을 false로 설정하고 위의 메타데이터 끝점을 제거하십시오. --> <serviceMetadata httpGetEnabled="true"/> <serviceThrottling maxConcurrentCalls="50" maxConcurrentSessions="50" maxConcurrentInstances="100"/> <!-- 디버깅 목적으로 오류에서 예외 정보를 받으려면 아래의 값을 true로 설정하십시오. 예외 정보를 공개하지 않으려면 배포하기 전에 false로 설정하십시오. --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> |
그리고 다시 테스트를 해보시면 Lock 이 걸리지 않는 것을 확인할 수 있습니다.
이 옵션은 아래와 같은 튜닝하는 것이 좋다고 가이드 합니다. 단지 권장 값이기 때문에 더 높은 값을 주어도 상관은 없습니다. 특히 MaxConcurrentInstances 는 Int32.MaxValue 값을 주셔도 됩니다. WCF 어플리케이션 서버의 배치와 Load-Balancing 을 고려하여 적절하게 주시면 됩니다.
| 기본 값 | 권장 값 | 예 (4-Core) |
MaxConcurrentSessions | 10 | 기본 값 * CPUs | 40 |
MaxConcurrentCalls | 16 | 기본 값 * CPUs | 64 |
MaxConcurrentInstances | 26 | 권장 값의 MaxConcurrentSessions + MaxConcurrentCalls | 104 |
2010년 1월 11일 월요일
쿠키 허용 확인하기
ie4, ie5는 Navigator 객체의 cookieEnabled 라는 요소가 있습니다. 사용 허용은 true 값을 가지고 있고 선택을 꺼놓은 허용 불가는 false 값을 가집니다. 그래서 아래로 cookie를 사용하게 선택해 놓았는지 알 수 있습니다.
if(navigator.cookieEnabled) {
cookie 작업 구문..
}
else alert("cookie를 꺼놓았습니다. 선택해 주세요..")
ie4, ie5에는 cookieEnabled 라는 요소로 알 수 있지만 nn4 이하는 이 요소가 없습니다. 그래서 직접적인 방법을 사용하지 않고 다른 방법을 사용하여야 합니다. 방법은 임시로 아무 cookie 값을 지정하고 그 cookie 값이 있는지 확인하는 방법입니다.document.cookie = 1
if(document.cookie) {
cookie 작업 구문..
}
else alert("cookie를 꺼놓았습니다. 선택해 주세요..")
cookie에 아무 값이나 지정하고 그 값을 사용하여 그것을 읽으면 굳이 cookie 지정여부를 말해주는 요소가 없어도 nn3 이상의 대부분의 브라우저에서 확인할 수 있습니다. AJAX 강의 (링크)
AJAX 강의 2장 - XMLHttpRequest 오브젝트 사용하기
AJAX 강의 3장 - 서버와 통신하기(요청/응답 처리)
AJAX 강의 4-1장 - 폼 입력값 검증 하기
AJAX 강의 4-2장 - 응답 헤더정보 다루기
AJAX 강의 4-3장 - 동적으로 리스트 박스 로딩하기
AJAX 강의 4-4장 - auto refresh 기능 구현하기
AJAX 강의 4-5장 - Progress Bar 기능 구현하기
AJAX 강의 4-6장 - 툴팁 구현하기
AJAX 강의 4-7장 - 동적으로 웹페이지 수정하기
AJAX 강의 4-8장 - 웹서비스 접근하기
AJAX 강의 4-9장 - 자동완성 기능 구현하기
AJAX 강의 5-1장 - JSDoc 을 이용한 자바스크립트 다큐먼트 생성하기
AJAX 강의 5-2장 - FireFox 확장기능을 이용한 HTML 코드검사
AJAX 강의 5-3장 - Dom Inspector 를 이용한 노드검색
AJAX 강의 5-4장 - 자바스크립트 소스코드 검증기 JSLint
AJAX 강의 5-5장 - 자바스크립트 파일압축 및 Obfuscation
AJAX 강의 5-6장 - Web Developer Extension for FireFox
AJAX 강의 5-7장 - 자바스크립트 심화학습/객체지향(상속)
AJAX 강의 5-8장 - 자바스크립트 심화학습/객체지향(은닉)
AJAX 강의 5-9장 - 자바스크립트 심화학습/객체지향(종합)
AJAX 강의 6-1장 - JsUnit 활용/시작하기
AJAX 강의 6-2장 - JsUnit 활용/테스트 메소드작성
AJAX 강의 6-3장 - JsUnit 활용/setUp & tearDown 메소드
AJAX 강의 6-4장 - JsUnit 활용/setUpPage 메소드
AJAX 강의 6-5장 - JsUnit 활용/Tracing and Logging
AJAX 강의 6-6장 - JsUnit 활용/page timeout 필드
AJAX 강의 6-7장 - JsUnit 활용/Progress bar 및 상태표시 필드
AJAX 강의 6-8장 - JsUnit 활용/쿼리 스트링 사용하기
AJAX 강의 7-1장 - 디버깅툴/XMLHttpRequest Debugging
AJAX 강의 7-2장 - 디버깅툴/FireFox 자바스크립트 콘솔
AJAX 강의 7-3장 - 디버깅툴/Microsoft Script Debugger
AJAX 강의 7-4장 - 디버깅툴/Venkman
AJAX 강의 7-4장 - 디버깅툴/Venkman(계속)
2009년 11월 4일 수요일
루프를 돌면서 DataTable의 DataRow를 삭제할때
행의 RowState가 Added이면 행이 테이블에서 제거됩니다.
Delete 메서드를 사용한 후에는 RowState가 Deleted로 됩니다. AcceptChanges를 호출하기 전까지는 Deleted로 유지됩니다.
RejectChanges를 호출하여 삭제된 행의 삭제를 취소할 수 있습니다.
2009년 10월 26일 월요일
jQuery로 만들 수 있는 화끈한 첨단 효과
Many of us have been using a good deal of jQuery plugins lately. Below I have provided a list of the 50 favorite plugins many developers use. Some of these you may have already seen, others might be new to you. This is just the first series , the second version will be coming soon, stay tuned and Enjoy!
Sliding Panels
1) Sliding Panels For jQuery – Element can start open or closed and will be toggled from their own original position.
2) jQuery Collapse -A plugin for jQuery to collapse content of div container.
Menu
3) LavaLamp
4) A Navigation Menu- Unordered List with anchors and nested lists, also demonstrates how to add a second level list.
Tabs
6) jQuery UI Tabs / Tabs 3 – Simple jQuery based tab-navigation
7) TabContainer Theme – JQuery style fade animation that runs as the user navigates between selected tabs.
Accordion
8 ) jQuery Accordion
9) Simple JQuery Accordion menu
SlideShows
10) jQZoom- allows you to realize a small magnifier window close to the image or images on your web page easily.
11) Image/Photo Gallery Viewer- allows you to take a grouping of images and turn it into an flash-like image/photo gallery. It allows you to style it how ever you want and add as many images at you want.
Transition Effects
12) InnerFade – It’s designed to fade you any element inside a container in and out.
13) Easing Plugin- A jQuery plugin from GSGD to give advanced easing options. Uses Robert Penners easing equations for the transitions
14) Highlight Fade
15) jQuery Cycle Plugin- have very intersting transition effects like image cross-fading and cycling.
jQuery Carousel
16) Riding carousels with jQuery – is a jQuery plugin for controlling a list of items in horizontal or vertical order.
Color Picker
17) Farbtastic – is a jQuery plug-in that can add one or more color picker widgets into a page through JavaScript.
LightBox
19) jQuery ThickBox – is a webpage user interface dialog widget written in JavaScript.
20) SimpleModal Demos – its goal is providing developers with a cross-browser overlay and container that will be populated with content provided to SimpleModal.
21) jQuery lightBox Plugin – simple, elegant, unobtrusive, no need extra markup and is used to overlay images on the current page through the power and flexibility of jQuery´s selector.
iframe
22) JQuery iFrame Plugin – If javascript is turned off, it will just show a link to the content. Here is the code in action…
Form Validation
23) Validation – A fairly comprehensive set of form validation rules. The plugin also dynamically creates IDs and ties them to labels when they are missing.
24) Ajax Form Validation – Client side validation in a form using jQuery. The username will check with the server whether the chosen name is a) valid and b) available.
25) jQuery AlphaNumeric – Allows you to prevent your users from entering certain characters inside the form fields.
Form Elements
26) jquery.Combobox – is an unobtrusive way of creating a HTML type combobox from a existing HTML Select element(s), a Demo is here.
27) jQuery Checkbox – Provides for the styling of checkboxes that degrades nicely when javascript is dsiabled.
28) File Style Plugin for jQuery -File Style plugin enables you to use image as browse button. You can also style filename field as normal textfield using css.
Star Rating
ToolTips
31) Tooltip Plugin Examples – A fancy tooltip with some custom positioning, a tooltip with an extra class for nice shadows, and some extra content. You can find a demo here.
Tables Plugins
33) Zebra Tables Demo -using jQuery to do zebra striping and row hovering, very NICE!!
34) Table Sorter Plugin - for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. It can successfully parse and sort many types of data including linked data in a cell.
35) AutoScroll for jQuery -allows for hotspot scrolling of web pages
36) Scrollable HTML table plugin- used to convert tables in ordinary HTML into scrollable ones. No additional coding is necessary.
Draggable Droppables And Selectables
37) Sortables - You won’t believe how easy this code to make it easy to sort several lists, mix and match the lists, and send the information to a database.
38) Draggables and droppables- A good example of using jQuery plugin iDrop to drag and drop tree view nodes.
Style Switcher
39) Switch stylesheets with jQuery- allows your visitors to choose which stylesheet they would like to view your site with. It uses cookies so that when they return to the site or visit a different page they still get their chosen stylesheet. A Demo is here.
Rounded Corners
41) JQuery Curvy Corners- A plugin for rounded corners with smooth, anti-aliased corners.
Must See jQuery Examples
42) jQuery Air – A passenger management interface for charter flights. A great Tutorial that you will enjoy.
43) HeatColor -allows you to assign colors to elements, based on a value derived from that element. The derived value is compared to a range of values, it can find the min and max values of the desired elements, or you can pass them in manually.
44) Simple jQuery Examples -This page contains a growing set of Query powered script examples in "pagemod" format. The code that is displayed when clicking "Source" is exactly the same Javascript code that powers each example. Feel free to save a copy of this page and use the example.
45) Date Picker -A flexible unobtrusive calendar component for jQuery.
46) ScrollTo -A plugin for jQuery to scroll to a certain object in the page
47) 3-Column Splitter Layout -this is a 3-column layout using nested splitters. The left and right columns are a semi-fixed width; the center column grows or shrinks. Page scroll bars have been removed since all the content is inside the splitter, and the splitter is anchored to the bottom of the window using an onresize event handler.
48) Pager jQuery -Neat little jQuery plugin for a a paginated effect.
51) JQuery BlockUI Plugin -lets you simulate synchronous behavior when using AJAX, without locking the browser. When activated, it will prevent user activity with the page (or part of the page) until it is deactivated. BlockUI adds elements to the DOM to give it both the appearance and behavior of blocking user interaction.
출처 : http://www.noupe.com/jquery/50-amazing-jquery-examples-part1.html