Page History
...
OOP(Object-oriented programming)
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
public class DeepThought { private int state; public int State { get { lock (this) { Thread.Sleep(3000); //나의 상태에대한 깊은 생각에 빠짐..나는누군가? 여긴어딘가? return state; } } set { lock (this) { //깊은 생각에 빠질땐 누구도 건들지 말기를 바람,그대가 최고우선순위 스레드라할지라도 state = value; } } } } var dt = new DeepThought() Thread.new { console.log( dt.State ) } Thread.new { dt.State=1 } |
...
ActorSystem이 해야할일이며, 개발코드와 분리하여 옵션화를 통한 튜닝의 문제입니다. ( http://doc.akka.io/docs/akka/2.5.3/scala/dispatchers.html )
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
public class MyActor: ReceiveActor { //Actor모델 에서는 안전한 동시성처리를 위해 어떠한 프로퍼티(속성)도 공유가 필요없음으로, 속성 접근제한에 priave만으로 충분합니다. private readonly ILoggingAdapter log = Context.GetLogger(); private int state =0; public MyActor() { Receive<string>(message => { log.Info("Received String message: {0}", message); Sender.Tell(state ); }); Receive<SomeMessage>(message => {...}); } } //코드 변경 최소로 옵션만으로 로컬,원격,클러스터등러등의 작동 선택 전략이 가능하다. var remoteActor = system.ActorSelection("akka.tcp://MyServer@127.0.0.1:8001/user/someActor"); // 질의를 하던지?(Ask), 단지 말만한다던지?(Tell), 결과를 기다리던지(Result)? // 객체 접근 기반이아닌 메시지 전송기반의 인터페이스를 사용하는 조금더 추상화된 모델이다. // Tell의 의미를 상세히 분석하면, 내가 한말에 결과값이 필요없으니 처리만해달라란 의미이며 // 네트워크상의 의미로 수행결과가 있어도 어떠한 값을 리턴한다고 해도, 결과메시지 자체가 발송되지 않습니다. var state = remoteActor.Ask("Hello").Result; |
...
-번외 문서 : 서버 개발자의 성능 튜닝에대한 고뇌
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
my-blocking-dispatcher { type = Dispatcher executor = "thread-pool-executor" thread-pool-executor { fixed-pool-size = 16 } throughput = 1 } //이것은 런타임 코드가 아니라, 설정사항입니다. AKKA에서는 Thread를 직접 생성하는 코드를 작성하지 않습니다. //장비 1개 성능 최적화와 관련된 튜닝사항으로 스케일업과 관련이있습니다. |
...